feat(discord,bot): discord bot struct
This commit is contained in:
31
internals/discord/bot.go
Normal file
31
internals/discord/bot.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package discord
|
||||
|
||||
import (
|
||||
"dislate/internals/guilddb"
|
||||
"dislate/internals/translator"
|
||||
|
||||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
|
||||
type Bot struct {
|
||||
token string
|
||||
db guilddb.GuildDB
|
||||
translator translator.Translator
|
||||
session *discordgo.Session
|
||||
}
|
||||
|
||||
func NewBot(token string, db guilddb.GuildDB, translator translator.Translator) (*Bot, error) {
|
||||
discord, err := discordgo.New("Bot " + token)
|
||||
if err != nil {
|
||||
return &Bot{}, err
|
||||
}
|
||||
|
||||
return &Bot{token, db, translator, discord}, nil
|
||||
}
|
||||
|
||||
func (b *Bot) Start() error {
|
||||
return b.session.Open()
|
||||
}
|
||||
func (b *Bot) Stop() error {
|
||||
return b.session.Open()
|
||||
}
|
||||
Reference in New Issue
Block a user