Ejemplo n.º 1
0
        private async Task Prefix(string prefix)
        {
            var    guild     = ServerStorage.GetGuild(Context.Guild);
            string oldprefix = guild.prefix;

            guild.prefix = prefix;
            await ReplyAsync("Your prefix has been changed from " + oldprefix + " to " + prefix);

            ServerStorage.SaveGuilds();
        }
Ejemplo n.º 2
0
        private async Task infot()
        {
            // Add a mod log to the guild collected from guildstorage and create the channel
            var guild = ServerStorage.GetGuild(Context.Guild);

            await ReplyAsync("Adding a moderation log to this guild...");

            IGuildChannel chnl = await Context.Guild.CreateTextChannelAsync("mod-log");

            guild.Modlog   = true;
            guild.Modlogid = chnl.Id;
            ServerStorage.SaveGuilds();
            await ReplyAsync("Your guild now has a moderation log. To remove this log type -removemodlog");
        }
Ejemplo n.º 3
0
        private async Task RemoveModLog()
        {
            // Remove the modlog from the guild collected from guildstorage and remove the channel
            var guild = ServerStorage.GetGuild(Context.Guild);
            var chnl  = Context.Guild.GetChannel(guild.Modlogid);

            await ReplyAsync("Now removing modlog from your guild...");

            await chnl.DeleteAsync();

            guild.Modlogid = 0;
            guild.Modlog   = false;
            ServerStorage.SaveGuilds();
            await ReplyAsync("Your guild no longer has a moderation log");
        }
Ejemplo n.º 4
0
        private async Task HandleCommandAsync(SocketMessage arg)
        {
            var           message = arg as SocketUserMessage;                        // Create a variable with the message as SocketUserMessage
            IGuildChannel chnl    = (IGuildChannel)arg.Channel;                      // Define the current channel
            var           guild   = ServerStorage.GetGuild((SocketGuild)chnl.Guild); // Get the data for the current guild

            if (message is null || message.Author.IsBot)
            {
                return;                                                                                                                                                                      // Checks if the message is empty or sent by a bot
            }
            int argumentPos = 0;                                                                                                                                                             // Sets the argpos to 0 (the start of the message)

            if (message.HasStringPrefix(guild.prefix, ref argumentPos) || message.HasMentionPrefix(_client.CurrentUser, ref argumentPos) || message.HasStringPrefix("ab-", ref argumentPos)) // If the message has the prefix at the start or starts with someone mentioning the bot
            {
                var context = new SocketCommandContext(_client, message);                                                                                                                    // Create a variable called context
                var result  = await _commands.ExecuteAsync(context, argumentPos, _services);                                                                                                 // Create a veriable called result
            }
        }
Ejemplo n.º 5
0
        private async Task Kick(IGuildUser user = null, [Remainder] string reason = "reason not set")
        {
            // If an invalid user is chosen, notify the user
            if (user == null)
            {
                await ReplyAsync("Invalid User");
            }
            else
            {
                // Delete the context message and send the kicked message
                await Context.Message.DeleteAsync();
                await ReplyAsync("Kicked " + user.Username + " for " + reason);

                // Get the guild and save all guilds
                var guild = ServerStorage.GetGuild(Context.Guild);
                ServerStorage.SaveGuilds();

                if (guild.Modlog)
                {
                    // Create a modlog embed and send it to the modlog
                    var eb = new EmbedBuilder();
                    eb.WithColor(Color.Teal);
                    eb.WithCurrentTimestamp();
                    eb.WithTitle("A user has been kicked!");
                    if (user.IsBot)
                    {
                        eb.WithTitle("A bot has been kicked!");
                        eb.AddField("Bot", user.Username, true);
                    }
                    else
                    {
                        eb.WithTitle("A user has been kicked!");
                        eb.AddField("User", user.Username, true);
                    }
                    eb.AddField("Moderator", Context.Message.Author.Username, true);
                    eb.AddField("Reason", reason, true);
                    eb.WithThumbnailUrl(user.GetAvatarUrl());
                    SocketTextChannel ml = (SocketTextChannel)Context.Guild.GetChannel(guild.Modlogid);
                    var ebb = eb.Build();
                    await ml.SendMessageAsync("", false, ebb);
                }
                await user.KickAsync(reason);
            }
        }
Ejemplo n.º 6
0
        private async Task DBG()
        {
            // Variable definitions
            var guild             = ServerStorage.GetGuild(Context.Guild);
            SocketTextChannel log = (SocketTextChannel)Context.Guild.GetChannel(guild.Modlogid);

            // Notify the user
            await ReplyAsync("Sending a test message to your modlog");

            // Create the embed and send it to the modlog
            var eb = new EmbedBuilder();

            eb.WithTitle("This is a moderation log test message");
            eb.WithCurrentTimestamp();
            eb.WithColor(Color.Blue);
            eb.WithDescription("This is a test message to test your servers mod log sent from " + Context.Message.Author.Username);
            var ebb = eb.Build();
            await log.SendMessageAsync("", false, ebb);

            await ReplyAsync("The message has been sent successfully ");
        }