C
C#2y ago
malkav

✅ Discord.NET InteractionModule issues

Okay so I followed this guy to setup a base skeleton for my Discord.NET bot, however I do not get my commands to actually reply or respond to my calls, but they do get registered to the guild. I added some Console.WriteLine methods in there to see until where it was being called. It seems that the actual HandleSomeCommand() methods are not being called, and the class InteractionModule gives me the This class is not being used like message. Not a warning or error per-se, but I believe I'm missing something.. Link to tutorial for reference: https://www.youtube.com/watch?v=fvVWIPgfYdA&ab_channel=CrenstonCustoms-Coding (this is ep 3) I'm not actually sure where to look for "missing" pieces, so here's a list of hastebins for my code:
Program.cs https://hastebin.com/izaquqasos.csharp Ready.cs https://hastebin.com/olamedevur.csharp InteractionHandler.cs https://hastebin.com/uxiqokoloh.csharp InteractionModule.cs https://hastebin.com/gucuxaneki.cpp
the last Console.WriteLine I am getting in from my bot, when I use a slashCommand, is the line Handling interaction from the InteractionHandler.cs at line: 31 What am I missing?? (note: I don't believe any secrets are in the code, but if they are, after finishing the bot, these secrets will be re-generated)
5 Replies
malkav
malkav2y ago
I've updated my InteractionHandler.cs file: https://hastebin.com/ehahalewex.csharp
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
malkav
malkav2y ago
yea, the reason I extended this extension is because I needed the interaction Context, found that in the documents I think, lemme find the reference again.. Anyways, the reason I did InteractionModulebase<SocketInteractionContext<SocketMessageComponent>> was because I needed to be able to call Context.Interaction.User but I'll see if that is the issue. Lemme remove that part for a second well I'll be fucked... apparently that is the issue... Hrm, or not... the Ping command worked, but not the Embed command.. (roll)
public class InteractionModule : InteractionModuleBase<SocketInteractionContext>
{
[SlashCommand("roll", "Rolling D10's for the Vtm V5 game as per the old Bloodbot")]
public async Task HandleRollCommand(
[Summary("Pool", "The amount of dice to use, max 10")]int pool,
[Summary("Hunger", "The hunger value of your character, max 5")]int hunger = 0,
[Summary("Difficulty", "The difficulty of the roll.")]int diff = 0 )
{
Embed embed = await new Roll(Context.Interaction.User, pool, hunger, diff).RunEmbedResult();
try
{
Console.WriteLine("I am trying to send dice rolls");
await RespondAsync(text: "rolling dice", embed: embed);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}

[SlashCommand("ping", "pong")]
public async Task HandlePingCommand()
{
await RespondAsync("pong!");
}
}
public class InteractionModule : InteractionModuleBase<SocketInteractionContext>
{
[SlashCommand("roll", "Rolling D10's for the Vtm V5 game as per the old Bloodbot")]
public async Task HandleRollCommand(
[Summary("Pool", "The amount of dice to use, max 10")]int pool,
[Summary("Hunger", "The hunger value of your character, max 5")]int hunger = 0,
[Summary("Difficulty", "The difficulty of the roll.")]int diff = 0 )
{
Embed embed = await new Roll(Context.Interaction.User, pool, hunger, diff).RunEmbedResult();
try
{
Console.WriteLine("I am trying to send dice rolls");
await RespondAsync(text: "rolling dice", embed: embed);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}

[SlashCommand("ping", "pong")]
public async Task HandlePingCommand()
{
await RespondAsync("pong!");
}
}
So I am getting pong! when I call /ping from my bot. But not the /roll result..
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
malkav
malkav2y ago
I managed to figure it out, but thanks for your help!
Want results from more Discord servers?
Add your server
More Posts