#Trouble sending messages with slash commands
1 messages · Page 1 of 1 (latest)
public class CatCommands : ApplicationCommandModule
{
[SlashCommand("catboy", "sends an image of a catboy")]
public async Task CatboyCommand(InteractionContext ctx)
{
RestClient rclient = new RestClient("https://api.catboys.com");
RestRequest request = new RestRequest("img");
RestResponse res = await rclient.GetAsync(request);
if (res.IsSuccessful)
{
var content = Configs.GetContent(res.Content);
string image = content.url;
DiscordEmbedBuilder CatboyEmbed = new DiscordEmbedBuilder
{
Color = DiscordColor.Red,
Title = "Here you go!",
Url = "https://catboys.com",
ImageUrl = image,
};
await ctx.Channel.SendMessageAsync(
embed: CatboyEmbed
);
}
else
{
await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().WithContent(
"Something went wrong with the request!"
));
}
}
}```
code
hans tag it doesnt work
Hi, so you've probably said something along the lines of " X doesn't work".
This is, frankly, useless! What is of use to us are the following
➜ Attempted debugging steps
➜ Expected result
➜ Stack trace, if applicable.
If you're dealing with "it doesn't work", but there's "no exception being thrown", there is, but you're not catching it. Subscribe to the appropriate __Errored event for the client or command framework in use.
so turns out, i was using the wrong thing.