part works

This commit is contained in:
lyx0 2021-10-28 16:20:27 +02:00
parent cb0181c01f
commit 4171d11dae
2 changed files with 37 additions and 0 deletions

32
pkg/db/partchannel.go Normal file
View file

@ -0,0 +1,32 @@
package db
import (
"context"
"time"
log "github.com/sirupsen/logrus"
)
func PartChannel(channelName string) {
// Interact with data
client := Connect()
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
/*
Get my collection instance
*/
collection := client.Database("nourybot").Collection("channels")
// Channel
chnl := Channel{channelName, true}
res, insertErr := collection.DeleteOne(ctx, chnl)
if insertErr != nil {
log.Error(insertErr)
}
log.Info(res)
}

View file

@ -144,6 +144,11 @@ func Command(message twitch.PrivateMessage, nb *bot.Bot) {
case "join":
db.AddChannel(cmdParams[1])
nb.Send(message.Channel, "Joined")
return
case "part":
db.PartChannel(cmdParams[1])
nb.Send(message.Channel, "Parted")
case "firstline":
if msgLen == 1 {