init commit
This commit is contained in:
71
Commands/GeneralCommands.cs
Normal file
71
Commands/GeneralCommands.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user