Ejemplo n.º 1
0
 public GuildMemberUpdatedNotification(
     ISocketGuildUser oldMember,
     ISocketGuildUser newMember)
 {
     OldMember = oldMember;
     NewMember = newMember;
 }
        private Task OnUserLeftAsync(ISocketGuildUser guildUser)
        {
            try
            {
                MessageDispatcher.Dispatch(new UserLeftNotification(guildUser));
            }
            finally
            {
                UpdateGuildPopulationCounter(guildUser?.Guild, "user_left");
            }

            return(Task.CompletedTask);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Mutes the user if they have an active mute infraction in the guild.
        /// </summary>
        /// <param name="guild">The guild that the user joined.</param>
        /// <param name="user">The user who joined the guild.</param>
        /// <returns>
        /// A <see cref="Task"/> that will complete when the operation completes.
        /// </returns>
        private async Task TryMuteUserAsync(ISocketGuildUser guildUser)
        {
            var userHasActiveMuteInfraction = await _moderationService.AnyInfractionsAsync(new InfractionSearchCriteria()
            {
                GuildId     = guildUser.GuildId,
                IsDeleted   = false,
                IsRescinded = false,
                SubjectId   = guildUser.Id,
                Types       = new[] { InfractionType.Mute },
            });

            if (!userHasActiveMuteInfraction)
            {
                Log.Debug("User {0} was not muted, because they do not have any active mute infractions.", guildUser.Id);
                return;
            }

            var muteRole = await _moderationService.GetOrCreateDesignatedMuteRoleAsync(guildUser.Guild, _discordSocketClient.CurrentUser.Id);

            Log.Debug("User {0} was muted, because they have an active mute infraction.", guildUser.Id);

            await guildUser.AddRoleAsync(muteRole);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Constructs a new <see cref="UserLeftNotification"/> from the given values.
 /// </summary>
 /// <param name="guildUser">The value to use for <see cref="GuildUser"/>.</param>
 /// <exception cref="ArgumentNullException">Throws for <paramref name="guildUser"/>.</exception>
 public UserLeftNotification(ISocketGuildUser guildUser)
 {
     GuildUser = guildUser ?? throw new ArgumentNullException(nameof(guildUser));
 }
Ejemplo n.º 5
0
        private Task OnUserLeftAsync(ISocketGuildUser guildUser)
        {
            MessageDispatcher.Dispatch(new UserLeftNotification(guildUser));

            return(Task.CompletedTask);
        }
Ejemplo n.º 6
0
        private Task OnGuildMemberUpdatedAsync(ISocketGuildUser oldMember, ISocketGuildUser newMember)
        {
            MessageDispatcher.Dispatch(new GuildMemberUpdatedNotification(oldMember, newMember));

            return(Task.CompletedTask);
        }