Rename var DiscordClient to dg
This commit is contained in:
parent
b2b957e5c3
commit
8eaaaeab3e
14
discord.go
14
discord.go
|
@ -13,7 +13,7 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
DiscordToken string
|
DiscordToken string
|
||||||
DiscordClient *discordgo.Session
|
dg *discordgo.Session
|
||||||
DiscordChannelId string
|
DiscordChannelId string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -36,16 +36,16 @@ func init() {
|
||||||
|
|
||||||
func initBot() {
|
func initBot() {
|
||||||
var err error
|
var err error
|
||||||
DiscordClient, err = discordgo.New("Bot " + DiscordToken)
|
dg, err = discordgo.New("Bot " + DiscordToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("error creating discord session:", err)
|
log.Fatal("error creating discord session:", err)
|
||||||
}
|
}
|
||||||
DiscordClient.AddHandler(func(s *discordgo.Session, event *discordgo.Ready) {
|
dg.AddHandler(func(s *discordgo.Session, event *discordgo.Ready) {
|
||||||
log.Println("Logged in as", event.User.Username)
|
log.Println("Logged in as", event.User.Username)
|
||||||
})
|
})
|
||||||
DiscordClient.AddHandler(onMessage)
|
dg.AddHandler(onMessage)
|
||||||
DiscordClient.Identify.Intents = discordgo.IntentsGuildMessages | discordgo.IntentsMessageContent
|
dg.Identify.Intents = discordgo.IntentsGuildMessages | discordgo.IntentsMessageContent
|
||||||
err = DiscordClient.Open()
|
err = dg.Open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("error opening connection to discord: ", err, " -- Is your token correct?")
|
log.Fatal("error opening connection to discord: ", err, " -- Is your token correct?")
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ func SendDupesErrorToDiscord(dupesErr *DupesError) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func SendEmbedToDiscord(embed *discordgo.MessageEmbed) {
|
func SendEmbedToDiscord(embed *discordgo.MessageEmbed) {
|
||||||
_, err := DiscordClient.ChannelMessageSendEmbed(DiscordChannelId, embed)
|
_, err := dg.ChannelMessageSendEmbed(DiscordChannelId, embed)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("Error during json.Marshal:", err)
|
log.Fatal("Error during json.Marshal:", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue