hello and send messages

This commit is contained in:
Vilmos Zsombor TANCZOS 2025-04-28 14:17:01 +02:00
parent 61b0fdf733
commit 4187f4269a
4 changed files with 89 additions and 0 deletions

14
Commands/HelloModule.cs Normal file
View file

@ -0,0 +1,14 @@
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
namespace KBot;
public class HelloModule : BaseCommandModule
{
[Command("greet")]
[RequireRoles(RoleCheckMode.All, "Admin")]
public async Task GreetCommand(CommandContext ctx)
{
await ctx.RespondAsync("Greetings! Thank you for executing me!");
}
}

43
Commands/SendModule.cs Normal file
View file

@ -0,0 +1,43 @@
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
namespace KBot;
public class SendModule : BaseCommandModule
{
[
Command("send"),
Description("Lets you send a message to a channel, user, or in reply to a message"),
RequireRoles(RoleCheckMode.All, "Admin")
]
public async Task SendChannelCommand(
CommandContext ctx,
[Description("The channel the message will be sent to")] DiscordChannel channel,
[RemainingText, Description("The message sent")] string content
)
{
await ctx.Client.SendMessageAsync(channel, content);
}
[Command("send"), RequireRoles(RoleCheckMode.All, "Admin")]
public async Task SendDmCommand(
CommandContext ctx,
[Description("The member you want to send the message to")] DiscordMember member,
[RemainingText, Description("The message sent")] string content
)
{
var channel = await member.CreateDmChannelAsync();
await ctx.Client.SendMessageAsync(channel, content);
}
[Command("send"), RequireRoles(RoleCheckMode.All, "Admin")]
public async Task SendReplyCommand(
CommandContext ctx,
[Description("The message you want to reply to")] DiscordMessage message,
[RemainingText, Description("The message sent")] string content
)
{
await message.RespondAsync(content);
}
}