Пример #1
0
        public async Task AnnounceUnbannedUserAsync(SocketUser user, SocketGuild guild)
        {
            if (!BanChecks.GetIsCommandBan())
            {
                var server     = bot.Guilds.FirstOrDefault(x => x.Id == BotConfig.Load().ServerId);
                var logChannel = server.GetTextChannel(BotConfig.Load().LogsId);

                var logEmbed = new EmbedBuilder()
                {
                    Color = Colours.adminCol
                };
                logEmbed.WithAuthor("User was unbanned from Discord");
                logEmbed.WithThumbnailUrl(References.GetGta5policeLogo());
                logEmbed.AddField(new EmbedFieldBuilder()
                {
                    Name = "Discord User", Value = user.Username.ToString(), IsInline = true
                });
                logEmbed.AddField(new EmbedFieldBuilder()
                {
                    Name = "DiscordId", Value = user.Id, IsInline = true
                });

                await logChannel.SendMessageAsync("", false, logEmbed);

                Statistics.AddOutgoingMessages();
            }
            BanChecks.ResetIsCommandBan();
        }
Пример #2
0
        public async Task KickAsync(IUser user = null, [Remainder] string reason = null)
        {
            Errors errors = new Errors();

            if (user == null)
            {
                await errors.sendErrorTempAsync(Context.Channel, "Please mention the user you would like to kick.", Colours.errorCol);
            }
            if (reason == null)
            {
                await errors.sendErrorTempAsync(Context.Channel, "Please provide a reason for the kick!", Colours.errorCol);
            }

            if (user != null && reason != null)
            {
                await Context.Message.DeleteAsync();

                await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                {
                    Color = Colours.adminCol, ImageUrl = "https://media1.giphy.com/media/3o7TKwVQMoQh2At9qU/giphy.gif", Title = "User kicked from the server!"
                });

                BanChecks.SetIsCommandBan();

                var userName = user as SocketGuildUser;
                await userName.KickAsync();

                //await Context.Guild.AddBanAsync(user, 0, reason);
                //await Context.Guild.RemoveBanAsync(user);

                IUser    kickHammerOwner = Context.Message.Author;
                int      kickDay         = DateTime.Now.Day;
                int      kickMonth       = DateTime.Now.Month;
                int      kickYear        = DateTime.Now.Year;
                TimeSpan kickTime        = DateTime.Now.TimeOfDay;

                var embed = new EmbedBuilder()
                {
                    Color = Colours.errorCol
                };
                embed.WithAuthor("User was kicked from Discord");
                embed.WithThumbnailUrl(References.GetGta5policeLogo());
                embed.AddField(new EmbedFieldBuilder()
                {
                    Name = "Discord User", Value = user.Username.ToString(), IsInline = true
                });
                embed.AddField(new EmbedFieldBuilder()
                {
                    Name = "Discord Id", Value = user.Id, IsInline = true
                });
                embed.AddField(new EmbedFieldBuilder()
                {
                    Name = "Reason", Value = reason, IsInline = false
                });
                embed.AddField(new EmbedFieldBuilder()
                {
                    Name = "Kicked By", Value = kickHammerOwner, IsInline = true
                });
                embed.AddField(new EmbedFieldBuilder()
                {
                    Name = "Time", Value = kickMonth + "/" + kickDay + "/" + kickYear + " - " + kickTime, IsInline = true
                });

                var chan = await Context.Guild.GetTextChannelAsync(BotConfig.Load().LogsId);

                await chan.SendMessageAsync("", false, embed);

                await Program.Logger(new LogMessage(LogSeverity.Info, "GTA5Police Admin Commands", "Kick command was used by " + Context.User + " on the user " + user + "."));

                Statistics.AddOutgoingMessages();
            }
        }