Beispiel #1
0
 public static async Task AddOrUpdateReactRole(ReactRole rrl)
 {
     await NonQueryFunctionCreator(
         $"REPLACE INTO reactroles VALUES ({rrl.ChannelId}, {rrl.MessageId}, {rrl.GuildId}, {Convert.ToInt32(rrl.Unique)}, \"{string.Join(',', rrl.Emojis)}\", \"{string.Join(',', rrl.Roles.Select(x => $"{x}"))}\", \"{string.Join(',', rrl.BlackListedRoles.Select(x => $"{x}"))}\", \"{string.Join(',', rrl.WhiteListedRoles.Select(x => $"{x}"))}\", \"{rrl.SelfDestructTime:u}\");");
 }
Beispiel #2
0
        public async Task AddEmoteRoles(IRole role, string emoteString = "", string name = "")
        {
            if (!_reactRoleService.IsPreparingMessage)
            {
                await ReplyAsync("No message is being prepared, use NewMessage first!");

                return;
            }

            // If empty we check the message for the role passed in, if it exists we remove that role from the message.
            if (emoteString == string.Empty)
            {
                var reactionRemove =
                    _reactRoleService.NewMessage.Reactions?.Find(reactRole => reactRole.RoleId == role.Id);
                if (reactionRemove == null)
                {
                    await ReplyAsync($"Role {role.Name} was not attached to this message.");

                    return;
                }

                _reactRoleService.NewMessage.Reactions.Remove(reactionRemove);
                await ReplyAsync($"Removed Role {role.Name} from message.");

                return;
            }

            // Try pull the Emote ID from the emote used.
            Emote tempEmote;

            if (!Emote.TryParse(emoteString, out tempEmote))
            {
                await ReplyAsync($"Emote ({emoteString}) does not exist in this server.");

                return;
            }

            // We make sure we have access to it on this server
            var emote = await Context.Guild.GetEmoteAsync(tempEmote.Id);

            if (emote == null)
            {
                await ReplyAsync($"Failed to use ({emoteString}), unknown error.");

                return;
            }

            if (name == string.Empty)
            {
                name = emote.Name;
            }

            // Add our Reaction Role
            _reactRoleService.NewMessage.Reactions ??= new List <ReactRole>();
            var newRole = new ReactRole(name, role.Id, emote.Id);

            _reactRoleService.NewMessage.Reactions.Add(newRole);

            await Context.Message.AddReactionAsync(emote);

            await Context.Message.AddReactionAsync(_thumbUpEmote);
        }