[Bug]: RequireBotPermission on ChannelPermissions throws an error
MoonieGZ opened this issue · 3 comments
Check The Docs
- I double checked the docs and couldn't find any useful information.
Verify Issue Source
- I verified the issue was caused by Discord.Net.
Check your intents
- I double checked that I have the required intents.
Description
Running a SlashCommand for a command that requires the bot to have ViewChannel throws an exception when trying to run the precondition.
Version
3.9.0-20230302.10 from MyGet
Working Version
No response
Logs
Exception: Unknown channel type. (parameter 'channel')
at Discord.ChannelPermissions.All(IChannel channel)
at Discord.Interactions.RequireBotPermissionAttribute.d__12.MoveNext()
at Discord.Interactions.CommandInfo1.<>c__DisplayClass45_0.<<CheckPreconditionsAsync>g__CheckGroups|0>d.MoveNext() at Discord.Interactions.CommandInfo
1.d__45.MoveNext()
at Discord.Interactions.CommandInfo`1.d__42.MoveNext()
Sample
[DefaultMemberPermissions(GuildPermission.ManageGuild)]
[RequireBotPermission(GuildPermission.ManageWebhooks)]
[RequireBotPermission(ChannelPermission.ViewChannel)]
[SlashCommand("ls-alert", "Add or remove the daily Lost Sector notification to a channel in your server.")]
public async Task LsAlert()
{
await DeferAsync(true);
var channel = await Context.Client.GetChannelAsync((ulong) Context.Interaction.ChannelId!);
if(channel is not ITextChannel textChannel)
{
await FollowupAsync(
"This channel type cannot be set up for receiving alerts.");
return;
}
// Other stuff here...
}
Packages
Fergun.Interactive 1.6.0
Hmmm
I can't reproduce it anymore
Check if this got resolved in 3.10.0
If the issue still occurs - try running the branch from #2647 PR
Upd: since that PR got merged you could try latest packages from MyGet
Any updates on this? Is the issue resolved? Please close the issue if it's resolved.
Closing due to lack of followup