give feedback on commands

This commit is contained in:
stryan 2021-02-09 18:04:11 -05:00
parent 027d970c11
commit aac90dd113
2 changed files with 20 additions and 6 deletions

View File

@ -61,10 +61,6 @@ func (l *DiscordListener) guildCreate(s *discordgo.Session, event *discordgo.Gui
func (l *DiscordListener) messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { func (l *DiscordListener) messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
if l.Bridge.Mode == bridgeModeConstant {
return
}
// Ignore all messages created by the bot itself // Ignore all messages created by the bot itself
if m.Author.ID == s.State.User.ID { if m.Author.ID == s.State.User.ID {
return return
@ -83,9 +79,19 @@ func (l *DiscordListener) messageCreate(s *discordgo.Session, m *discordgo.Messa
return return
} }
prefix := "!" + l.Bridge.BridgeConfig.Command prefix := "!" + l.Bridge.BridgeConfig.Command
if l.Bridge.Mode == bridgeModeConstant && strings.HasPrefix(m.Content, prefix) {
l.Bridge.DiscordSession.ChannelMessageSend(m.ChannelID, "Constant mode enabled, manual commands can not be entered")
return
}
if strings.HasPrefix(m.Content, prefix+" link") { if strings.HasPrefix(m.Content, prefix+" link") {
// Look for the message sender in that guild's current voice states. // Look for the message sender in that guild's current voice states.
for _, vs := range g.VoiceStates { for _, vs := range g.VoiceStates {
if l.Bridge.Connected {
l.Bridge.DiscordSession.ChannelMessageSend(m.ChannelID, "Bridge already running, unlink first")
return
}
if vs.UserID == m.Author.ID { if vs.UserID == m.Author.ID {
log.Printf("Trying to join GID %v and VID %v\n", g.ID, vs.ChannelID) log.Printf("Trying to join GID %v and VID %v\n", g.ID, vs.ChannelID)
l.Bridge.DiscordChannelID = vs.ChannelID l.Bridge.DiscordChannelID = vs.ChannelID
@ -97,8 +103,12 @@ func (l *DiscordListener) messageCreate(s *discordgo.Session, m *discordgo.Messa
if strings.HasPrefix(m.Content, prefix+" unlink") { if strings.HasPrefix(m.Content, prefix+" unlink") {
// Look for the message sender in that guild's current voice states. // Look for the message sender in that guild's current voice states.
if !l.Bridge.Connected {
l.Bridge.DiscordSession.ChannelMessageSend(m.ChannelID, "Bridge is not currently running")
return
}
for _, vs := range g.VoiceStates { for _, vs := range g.VoiceStates {
if vs.UserID == m.Author.ID { if vs.UserID == m.Author.ID && vs.ChannelID == l.Bridge.DiscordChannelID {
log.Printf("Trying to leave GID %v and VID %v\n", g.ID, vs.ChannelID) log.Printf("Trying to leave GID %v and VID %v\n", g.ID, vs.ChannelID)
l.Bridge.BridgeDie <- true l.Bridge.BridgeDie <- true
return return
@ -108,6 +118,10 @@ func (l *DiscordListener) messageCreate(s *discordgo.Session, m *discordgo.Messa
if strings.HasPrefix(m.Content, prefix+" refresh") { if strings.HasPrefix(m.Content, prefix+" refresh") {
// Look for the message sender in that guild's current voice states. // Look for the message sender in that guild's current voice states.
if !l.Bridge.Connected {
l.Bridge.DiscordSession.ChannelMessageSend(m.ChannelID, "Bridge is not currently running")
return
}
for _, vs := range g.VoiceStates { for _, vs := range g.VoiceStates {
if vs.UserID == m.Author.ID { if vs.UserID == m.Author.ID {
log.Printf("Trying to refresh GID %v and VID %v\n", g.ID, vs.ChannelID) log.Printf("Trying to refresh GID %v and VID %v\n", g.ID, vs.ChannelID)

View File

@ -193,7 +193,7 @@ func main() {
<-sc <-sc
// Signal the bridge to exit cleanly // Signal the bridge to exit cleanly
Bridge.BridgeDie <- true close(Bridge.BridgeDie)
log.Println("OS Signal. Bot shutting down") log.Println("OS Signal. Bot shutting down")