-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSuggestCommand.cs
46 lines (40 loc) · 1.99 KB
/
SuggestCommand.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using DSharpPlus;
using DSharpPlus.Entities;
using DSharpPlus.SlashCommands;
using System;
using System.Threading.Tasks;
namespace HyBot.Commands {
public class SuggestCommand : ApplicationCommandModule {
[SlashCommand("suggest", "Suggest a new feature for the bot.")]
public async Task SuggestCommandAsync(InteractionContext ctx,
[Option("suggestion", "Your suggestion.")] string suggestion) {
// Get the suggestion channel
var suggestionChannel = ctx.Guild.GetChannel(1088113798939955321);
// Check if the suggestion channel exists
if (suggestionChannel == null || suggestionChannel.Type != ChannelType.Text)
{
await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource,
new DiscordInteractionResponseBuilder().WithContent("The suggestion channel was not found."));
return;
}
// Create the embed for the suggestion
var embed = new DiscordEmbedBuilder()
.WithTitle("New suggestion")
.WithDescription(suggestion)
.WithFooter(
$"Suggestion made by {ctx.User.Username} at {DateTime.Now.ToString("MM/dd/yyyy hh:mm tt")} in #{ctx.Channel.Name}")
.WithColor(DiscordColor.Green);
// Check if the user has a profile picture
if (ctx.User.AvatarUrl != null)
{
// Add the user's profile picture to the embed
embed.WithThumbnail(ctx.User.AvatarUrl);
}
// Send the embed to the suggestion channel
await suggestionChannel.SendMessageAsync(embed: embed.Build());
// Respond to the user to confirm that the suggestion was sent
await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource,
new DiscordInteractionResponseBuilder().WithContent("Thank you for your suggestion!"));
}
}
}