using DSharpPlus.CommandsNext; using DSharpPlus.CommandsNext.Attributes; using DSharpPlus.Entities; using System.Threading.Tasks; using T3k3rg0.Helpers; namespace T3k3rg0.Commands { public class ReactionRoleManager : BaseCommandModule { [Command("addreactionrole")] [Description("Hozzáad egy új reaction role-t ! reactionrole <üzenet> <@szerep>")] [HasAdminRole] public async Task AddReactionRole(CommandContext ctx, string channelInput, string messageInput, string emojiInput, DiscordRole role) { var channel = await IdExtractor.ExtractChannelId(channelInput, ctx.Client); if (channel == null) return; var message = await IdExtractor.ExtractMessageId(messageInput, channel); if (message == null) return; var emoji = await EmojiExtractor.ExtractAsync(emojiInput, ctx.Client); if (emoji == null) return; bool inserted = ReactionRoleStorage.TryAddReactionRole(message.Id, emoji.ToString(), role.Id); if (!inserted) return; await message.CreateReactionAsync(emoji); } [Command("removereactionrole")] [Description("Eltávolít egy meglévő reaction role-t ! removereactionrole <üzenet> ")] [HasAdminRole] public async Task RemoveReactionRole(CommandContext ctx, string channelInput, string messageInput, string emojiInput) { var channel = await IdExtractor.ExtractChannelId(channelInput, ctx.Client); if (channel == null) { return; } var message = await IdExtractor.ExtractMessageId(messageInput, channel); if (message == null) { return; } var emoji = await EmojiExtractor.ExtractAsync(emojiInput, ctx.Client); if (emoji == null) { return; } bool removed = ReactionRoleStorage.TryRemoveReactionRole(message.Id, emoji.ToString()); if (!removed) { return; } await message.DeleteOwnReactionAsync(emoji); } } }