mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
33 lines
524 B
Go
33 lines
524 B
Go
package db
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func AddChannel(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.InsertOne(ctx, chnl)
|
|
if insertErr != nil {
|
|
log.Error(insertErr)
|
|
}
|
|
log.Info(res)
|
|
|
|
}
|