added napiszar, using MsEntitiFramework, addreactionrole command working just with link
This commit is contained in:
parent
1695770f9f
commit
d508bffac1
9 changed files with 318 additions and 94 deletions
25
commands/napiszar.cs
Normal file
25
commands/napiszar.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using DSharpPlus.CommandsNext;
|
||||
using DSharpPlus.CommandsNext.Attributes;
|
||||
using System.Threading.Tasks;
|
||||
using T3k3rg0.Helpers;
|
||||
|
||||
namespace T3k3rg0.Commands
|
||||
{
|
||||
public class Napiszar : BaseCommandModule
|
||||
{
|
||||
[Command("napiszar")]
|
||||
[Description("Elküld egy napiszart.")]
|
||||
public async Task GetNapiszar(CommandContext ctx)
|
||||
{
|
||||
if (NapiszarService.HasUsedToday(ctx.User.Id))
|
||||
{
|
||||
await ctx.RespondAsync("Ma már megkaptad a szarodat");
|
||||
return;
|
||||
}
|
||||
|
||||
string napiszar = NapiszarService.GetRandomSzar();
|
||||
NapiszarService.LogUsage(ctx.User.Id);
|
||||
await ctx.RespondAsync(napiszar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ using DSharpPlus.CommandsNext;
|
|||
using DSharpPlus.CommandsNext.Attributes;
|
||||
using DSharpPlus.Entities;
|
||||
using System.Threading.Tasks;
|
||||
using System.Text;
|
||||
using T3k3rg0.Helpers;
|
||||
|
||||
namespace T3k3rg0.Commands
|
||||
|
|
@ -11,56 +12,66 @@ namespace T3k3rg0.Commands
|
|||
[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)
|
||||
public async Task AddReactionRole(CommandContext ctx, string messageLink, DiscordEmoji emoji, DiscordRole role)
|
||||
{
|
||||
var channel = await IdExtractor.ExtractChannelId(channelInput, ctx.Client);
|
||||
if (channel == null)
|
||||
var channel = await IdExtractor.ExtractChannelId(messageLink, ctx.Client);
|
||||
if (channel is 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)
|
||||
var message = await IdExtractor.ExtractMessageId(messageLink, channel);
|
||||
if (message is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ReactionRoleService.AddReactionRole(message.Id, emoji.ToString(), role.Id);
|
||||
await message.CreateReactionAsync(emoji);
|
||||
}
|
||||
|
||||
[Command("removereactionrole")]
|
||||
[Description("Eltávolít egy meglévő reaction role-t ! removereactionrole <csatorna> <üzenet> <emoji>")]
|
||||
[Description("Eltávolít egy meglévő reaction role-t ! removereactionrole <id>")]
|
||||
[HasAdminRole]
|
||||
public async Task RemoveReactionRole(CommandContext ctx, string channelInput, string messageInput, string emojiInput)
|
||||
public async Task RemoveReactionRole(CommandContext ctx, int id)
|
||||
{
|
||||
var channel = await IdExtractor.ExtractChannelId(channelInput, ctx.Client);
|
||||
if (channel == null)
|
||||
var result = await ReactionRoleService.RemoveReactionRoleByIdAsync(id);
|
||||
|
||||
if (!result.Success)
|
||||
{
|
||||
await ctx.RespondAsync(result.Message ?? "❌ Ismeretlen hiba történt.");
|
||||
return;
|
||||
}
|
||||
|
||||
var message = await IdExtractor.ExtractMessageId(messageInput, channel);
|
||||
if (message == null)
|
||||
await ctx.RespondAsync(result.Message ?? $"✅ A(z) {id}. reakció szerepkör törölve.");
|
||||
}
|
||||
[Command("listreactionrole")]
|
||||
[Description("Felsorolja a reaction role párosításokat.")]
|
||||
[HasAdminRole]
|
||||
public async Task ListReactionRoles(CommandContext ctx)
|
||||
{
|
||||
// Lekérjük az összes reakció alapú szerepkört az adatbázisból
|
||||
var allRoles = ReactionRoleService.GetAllReactionRoles();
|
||||
|
||||
if (allRoles.Count == 0)
|
||||
{
|
||||
await ctx.RespondAsync("❌ Nincs reakció alapú szerepkör a szerveren.");
|
||||
return;
|
||||
}
|
||||
|
||||
var emoji = await EmojiExtractor.ExtractAsync(emojiInput, ctx.Client);
|
||||
if (emoji == null)
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("📜 Reakció alapú szerepkörök:");
|
||||
|
||||
// Az összes szerepkör kiírása sorszámozva
|
||||
int index = 1;
|
||||
foreach (var role in allRoles)
|
||||
{
|
||||
return;
|
||||
var roleObj = ctx.Guild.GetRole(role.RoleId); // Az adott szerepkör lekérése
|
||||
sb.AppendLine($"{index}. Üzenet ID: {role.MessageId}, Emoji: {role.Emoji}, Szerepkör: {roleObj?.Name ?? "Nincs név"}");
|
||||
index++; // Növeljük a sorszámot
|
||||
}
|
||||
|
||||
bool removed = ReactionRoleStorage.TryRemoveReactionRole(message.Id, emoji.ToString());
|
||||
if (!removed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await message.DeleteOwnReactionAsync(emoji);
|
||||
await ctx.RespondAsync(sb.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue