Exemple #1
0
        public async Task Warn(IGuildUser user, [Remainder] string reason = "No reason provided")
        {
            //only allow the user in this context warn people who have a lower role than them
            if (Tools_and_Functions.GetHighestRolePosition(user, Context.Client) < Tools_and_Functions.GetHighestRolePosition(Context.Client.GetGuild(597798914606759959).GetUser(Context.User.Id), Context.Client) /*|| Context.User.Id == 374284798820352000*/)
            {
                await actions.LogInfraction(user, Context.User, Context.Channel, reason);

                //Build embeds
                Embed warnReplyEmbed = new EmbedBuilder
                {
                    Author = new EmbedAuthorBuilder
                    {
                        IconUrl = user.GetAvatarUrl(),
                        Name    = user.Username + " has been warned!"
                    },
                    Description = reason,
                    Color       = Color.Orange
                                  //add more statistics in later update
                }.Build();
                //reply to executor
                await ReplyAsync(embed : warnReplyEmbed);
            }
            else
            {
                await ReplyAsync("You cannot warn a user that has a equal or higher role than you");
            }
        }
        private async Task HandleCommandAsync(SocketMessage messageParam)
        {
            // Don't process the command if it was a system message
            var message = messageParam as SocketUserMessage;

            Console.WriteLine(message.Content);
            if (message == null)
            {
                return;
            }

            // Create a number to track where the prefix ends and the command begins
            int argPos = 0;

            //load mod commands for bot use
            Mod_Actions actions = new Mod_Actions();

            //detect for banned words
            if (AutoMod.WordFilter(message.Content, out string reason))
            {
                string link = "https://discordapp.com/channels/597798914606759959/" + message.Channel.Id + "/" + message.Id;
                await message.Channel.SendMessageAsync(":exclamation: :eyes: :exclamation: " + message.Author.Mention + ", you used the " + reason + " This will be logged and may be used against you. " + link);

                await actions.LogInfraction(message.Author, _client.CurrentUser, message.Channel, reason);

                return;
            }

            // Determine if the message is a command based on the prefix and make sure no bots trigger commands
            if (!(message.HasCharPrefix('!', ref argPos) ||
                  message.HasMentionPrefix(_client.CurrentUser, ref argPos)) ||
                message.Author.IsBot)
            {
                return;
            }

            Console.WriteLine(message.Content);
            // Create a WebSocket-based command context based on the message
            var context = new SocketCommandContext(_client, message);

            // Execute the command with the command context we just
            // created, along with the service provider for precondition checks.
            await _commands.ExecuteAsync(
                context : context,
                argPos : argPos,
                services : null);
        }