예제 #1
0
 // This event handler is called whenever a user's state changes, which we use to detect a change
 // in their game which they are listed as playing.
 public async Task VCR_HandleUserUpdated(SocketGuildUser before, SocketGuildUser after)
 {
     // If it wasn't a game update, we don't care
     if (before.Game.Equals(after.Game))
     {
         return;
     }
     // If the user isn't in a voice channel, we don't care
     if (after.VoiceChannel == null)
     {
         return;
     }
     // Now that we've ascertained it was a game change of a user within a voice channel:
     await VoiceChannelNaming.UpdateVoiceChannel(after.VoiceChannel);
 }
예제 #2
0
        // This event handler is used to determine when a user has left or joined a voice channel.
        // It also fires whenever they mute and unmute themselves.
        // TODO: exclude voice state changing (mute/deafen)
        public async Task VCR_HandleVoiceState(SocketUser user, SocketVoiceState before, SocketVoiceState after)
        {
            // If the UserVoiceState was not updated due to a change in voice channel, we have nothing to do.
            if (before.VoiceChannel.Equals(after.VoiceChannel))
            {
                return;
            }

            if (before.VoiceChannel != null)
            {
                await VoiceChannelNaming.UpdateVoiceChannel(before.VoiceChannel);
            }
            if (after.VoiceChannel != null)
            {
                await VoiceChannelNaming.UpdateVoiceChannel(after.VoiceChannel);
            }
        }
예제 #3
0
 // When the bot starts, we want to update all voice channels
 public async Task VCR_OnStartup()
 => await VoiceChannelNaming.UpdateAllVoiceChannels(await _Client.GetGuildsAsync());
예제 #4
0
 // This event handler is called when our bot joins a new guild. In this case, what we want to do
 // is update that guild's voice channel naming as per our script.
 // This is a seperate method to UpdateAllVoiceChannels to save some work.
 // VCR = VoiceChannelRename to reduce ambiguity between event handlers
 public async Task VCR_OnJoinedGuild(SocketGuild g)
 => await VoiceChannelNaming.UpdateGuildVoiceChannels(g);