Esempio n. 1
0
        public async Task OnRemoveReaction(string messageID, string emote, string role)
        {
            Emoji emoji = null;

            // Check that the emote exist.
            if (!Emote.TryParse(emote, out var emoteResult))
            {
                emoji = new Emoji(emote);
            }

            ulong realMessageID = 0;

            // Convert the string to a message ID.
            if (!ulong.TryParse(messageID, out realMessageID))
            {
                await ReplyAsync($"Invalid message ID.");

                return;
            }

            // Check that the message exist.
            IMessage tt = null;

            foreach (SocketTextChannel channel in Context.Guild.TextChannels)
            {
                tt = await channel.GetMessageAsync(realMessageID);

                if (tt != null)
                {
                    break;
                }
            }

            if (tt == null)
            {
                await ReplyAsync($"Could not find message with ID {tt.Content}.");

                return;
            }

            // Check that the role exist.
            SocketRole realRole = Context.Guild.Roles.FirstOrDefault(x => x.Name.ToLower() == role.ToLower());

            if (realRole == null)
            {
                await ReplyAsync($"Could not find role {role}.");

                return;
            }

            // Check result.
            string result = await roleService.RemoveReactRole(Context.Guild, tt, emoteResult, emoji, realRole);

            await ReplyAsync(result);

            guildsDefinition.SaveReactRoles();
        }