Files
TentacleBot/Commands/GeneralCommands.cs
Garret Patti 3064e93011 init commit
2026-07-04 20:43:38 -04:00

72 lines
2.2 KiB
C#

using Discord;
using Discord.Interactions;
namespace TentacleBot.Commands;
[Group("general", "General commands")]
public class GeneralCommands : InteractionModuleBase<SocketInteractionContext>
{
/// <summary>
/// Example ping command that responds with pong
/// </summary>
[SlashCommand("ping", "Responds with pong and latency")]
public async Task HandlePingAsync()
{
await DeferAsync();
var latency = Context.Client.Latency;
var embed = new EmbedBuilder()
.WithTitle("Pong!")
.WithDescription($"Latency: {latency}ms")
.WithColor(Color.Green)
.WithTimestamp(DateTimeOffset.UtcNow)
.Build();
await FollowupAsync(embed: embed);
}
/// <summary>
/// Example hello command with a user parameter
/// </summary>
[SlashCommand("hello", "Greet a user")]
public async Task HandleHelloAsync(
[Summary("user", "The user to greet")] IUser? user = null)
{
await DeferAsync();
var targetUser = user ?? Context.User;
var embed = new EmbedBuilder()
.WithTitle($"Hello, {targetUser.Username}!")
.WithDescription($"Nice to meet you! ?")
.WithThumbnailUrl(targetUser.GetAvatarUrl() ?? targetUser.GetDefaultAvatarUrl())
.WithColor(Color.Blue)
.WithTimestamp(DateTimeOffset.UtcNow)
.Build();
await FollowupAsync(embed: embed);
}
/// <summary>
/// Example command that shows bot information
/// </summary>
[SlashCommand("botinfo", "Display bot information")]
public async Task HandleBotInfoAsync()
{
await DeferAsync();
var bot = Context.Client.CurrentUser;
var embed = new EmbedBuilder()
.WithTitle("Bot Information")
.AddField("Name", bot?.Username, true)
.AddField("ID", bot?.Id, true)
.AddField("Created", bot?.CreatedAt.ToString("g"), true)
.AddField("Guilds", Context.Client.Guilds.Count, true)
.WithColor(Color.Purple)
.WithThumbnailUrl(bot?.GetAvatarUrl())
.WithTimestamp(DateTimeOffset.UtcNow)
.Build();
await FollowupAsync(embed: embed);
}
}