mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
little bit of cleanings
This commit is contained in:
parent
a707c1a53f
commit
d2a67305ea
|
@ -10,27 +10,21 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func AddChannel(target, channelName string, nb *bot.Bot) {
|
func AddChannel(target, channelName string, nb *bot.Bot) {
|
||||||
// Interact with data
|
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
/*
|
|
||||||
Get my collection instance
|
|
||||||
*/
|
|
||||||
collection := nb.MongoClient.Database("nourybot").Collection("channels")
|
collection := nb.MongoClient.Database("nourybot").Collection("channels")
|
||||||
|
|
||||||
// Channel
|
// Channel
|
||||||
// {{"name": string}, {"connect": bool}}
|
// {{"name": string}, {"connect": bool}}
|
||||||
chnl := Channel{channelName, true}
|
chnl := Channel{channelName, true}
|
||||||
|
|
||||||
res, insertErr := collection.InsertOne(ctx, chnl)
|
_, insertErr := collection.InsertOne(ctx, chnl)
|
||||||
if insertErr != nil {
|
if insertErr != nil {
|
||||||
nb.Send(target, fmt.Sprintf("Error trying to join %s", channelName))
|
nb.Send(target, fmt.Sprintf("Error trying to join %s", channelName))
|
||||||
log.Error(insertErr)
|
log.Error(insertErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
nb.Send(target, fmt.Sprintf("Joined %s", channelName))
|
|
||||||
log.Info(res)
|
|
||||||
|
|
||||||
|
nb.Send(target, fmt.Sprintf("Joined %s", channelName))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue