Пример #1
0
        public async Task KickUserAsync([RequireHigherHierarchyPrecondition][EnsureNotSelf] IUser user, [Remainder] string reason = "No reason provided.")
        {
            try
            {
                var dmChannel = await user.GetOrCreateDMChannelAsync();

                await dmChannel.SendMessageAsync("", false, new EmbedBuilder()
                {
                    Title = $"You were kicked from **{Context.Guild.Name}**",
                    Color = _moderation.GetColorFromInfractionType(InfractionType.Kick)
                }
                                                 .AddField($"Reason", reason)
                                                 .Build());
            }
            catch (Exception)
            {
                await ReplyAsync($"Could not dm user to notify him.");
            }

            var restUser   = await(await Context.Client.Rest.GetGuildAsync(Context.Guild.Id)).GetUserAsync(user.Id);
            var infraction = await _moderation.KickUserFromGuildAsync(restUser, Context.User.Id, reason);

            await ReplyAsync($"#{infraction.Id} | Kicked {user.Mention}.");
        }