added reactionrole manager
This commit is contained in:
parent
8274a22f1b
commit
1695770f9f
4 changed files with 133 additions and 1 deletions
|
|
@ -27,7 +27,6 @@ namespace T3k3rg0.Commands
|
|||
var emoji = await EmojiExtractor.ExtractAsync(emojiInput, ctx.Client);
|
||||
if (emoji == null)
|
||||
{
|
||||
await ctx.RespondAsync("Nem sikerült felismerni az emojit.");
|
||||
return;
|
||||
}
|
||||
await message.CreateReactionAsync(emoji);
|
||||
|
|
|
|||
67
commands/reactionrolemanager.cs
Normal file
67
commands/reactionrolemanager.cs
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
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 <csatorna> <üzenet> <emoji> <@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 <csatorna> <üzenet> <emoji>")]
|
||||
[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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue