/// <summary>
        ///     The asynchronous callback when a voice state update was received.
        /// </summary>
        /// <param name="voiceServer">the voice state data</param>
        /// <returns>a task that represents the asynchronous operation</returns>
        private Task OnVoiceStateUpdated(global::DSharpPlus.EventArgs.VoiceStateUpdateEventArgs eventArgs)
        {
            var sessionId     = eventArgs.GetSessionId();
            var guildId       = eventArgs.Before?.Channel?.Guild?.Id ?? eventArgs.After.Channel.Guild.Id;
            var oldVoiceState = new VoiceState(eventArgs.Before?.Channel?.Id, guildId, sessionId);
            var voiceState    = new VoiceState(eventArgs.After.Channel?.Id, guildId, sessionId);
            var args          = new Events.VoiceStateUpdateEventArgs(eventArgs.User.Id, voiceState, oldVoiceState);

            return(VoiceStateUpdated.InvokeAsync(this, args));
        }
        /// <summary>
        ///     The asynchronous callback when a voice state update was received.
        /// </summary>
        /// <param name="voiceServer">the voice state data</param>
        /// <returns>a task that represents the asynchronous operation</returns>
        private Task OnVoiceStateUpdated(global::DSharpPlus.EventArgs.VoiceStateUpdateEventArgs eventArgs)
        {
            // create voice states
            var oldVoiceState = eventArgs.Before?.Channel is null ? null : new VoiceState(
                eventArgs.Before.Channel.Id, eventArgs.Before.Guild.Id, eventArgs.Before.GetSessionId());

            var voiceState = eventArgs.After?.Channel is null ? null : new VoiceState(
                eventArgs.After.Channel.Id, eventArgs.After.Guild.Id, eventArgs.After.GetSessionId());

            // invoke event
            return(VoiceStateUpdated.InvokeAsync(this,
                                                 new Events.VoiceStateUpdateEventArgs(eventArgs.User.Id, voiceState, oldVoiceState)));
        }
Example #3
0
 /// <summary>
 ///     The asynchronous callback when a voice state update was received.
 /// </summary>
 /// <param name="voiceServer">the voice state data</param>
 /// <returns>a task that represents the asynchronous operation</returns>
 private Task OnVoiceStateUpdated(global::DSharpPlus.EventArgs.VoiceStateUpdateEventArgs eventArgs)
 {
     /* I should not be needing this
      * // create voice states
      * var oldVoiceState = eventArgs.Before?.Channel is null ? null : new VoiceState(
      *  eventArgs.Channel.Id, eventArgs.Guild.Id, eventArgs.Before.GetSessionId());
      *
      * var voiceState = eventArgs.After?.Channel is null ? null : new VoiceState(
      *  eventArgs.Channel.Id, eventArgs.Guild.Id, eventArgs.After.GetSessionId());
      *
      * // invoke event
      * return VoiceStateUpdated.InvokeAsync(this,
      *  new Events.VoiceStateUpdateEventArgs(eventArgs.User.Id, voiceState, oldVoiceState));*/
     return(Task.CompletedTask);
 }
        /// <inheritdoc/>
        /// <exception cref="ObjectDisposedException">thrown if the instance is disposed</exception>
        protected Task OnVoiceStateUpdated(DiscordClient _, global::DSharpPlus.EventArgs.VoiceStateUpdateEventArgs eventArgs)
        {
            // session id is the same as the resume key so DSharpPlus should be able to give us the
            // session key in either before or after voice state
            var sessionId = eventArgs.Before?.GetSessionId() ?? eventArgs.After.GetSessionId();

            // create voice state
            var voiceState = new VoiceState(
                voiceChannelId: eventArgs.After?.Channel?.Id,
                guildId: eventArgs.Guild.Id,
                voiceSessionId: sessionId);

            // invoke event
            return(VoiceStateUpdated.InvokeAsync(this,
                                                 new Events.VoiceStateUpdateEventArgs(eventArgs.User.Id, voiceState)));
        }