public sealed override void Handle(IExecutionEnvironment environment, MessageReceivedEvent e)
        {
            GuildSettings guildSettings = environment.GetGuildSettings(e.GuildId);
            string        fullCommand   = guildSettings.CommandPrefix + CommandName;
            string        messageText   = e.Text;

            if (messageText == fullCommand || messageText.StartsWith(fullCommand + " "))
            {
                int cutLength = fullCommand.Length;
                if (messageText.Length > cutLength && messageText[cutLength + 1] == ' ')
                {
                    ++cutLength;
                }
                Execute(environment, e, messageText.Substring(cutLength));
            }
        }
Esempio n. 2
0
        public override void Handle(IExecutionEnvironment environment, EmojiAddedEvent e)
        {
            if (e.Emoji.Channel.Id != environment.GetGuildSettings(e.GuildId).RoleGainChannelId)
            {
                return;
            }
            if (!EmojiDepends.ContainsKey(e.Emoji.Emote.Name))
            {
                return;
            }
            IRole role = e.Guild.GetRole(EmojiDepends[e.Emoji.Emote.Name]);

            if (role is null)
            {
                return;
            }
            e.Instigator.AddRoleAsync(role).RunSync();
        }