-
-
Notifications
You must be signed in to change notification settings - Fork 40
Guards TypeError: undefined is not a function #63
Comments
https://github.com/OwenCalvin/discord.ts/blob/slash/examples/guards/guards/Say.ts check above example for proper usage and let us know if issue persist |
Changed my code to export const SlashCommandPermission = (permissions: PermissionResolvable[] | PermissionResolvable) => {
const guard: GuardFunction<ArgsOf<'message'> | CommandInteraction> = async (data, client, next, guardDatas: GuardDatas) => {
console.log(data instanceof CommandInteraction);
if (data instanceof CommandInteraction) {
const perms = Array.isArray(permissions) ? permissions : [permissions];
const guildMember = data.guild.members.cache.get(data.member.user.id);
const hasPermissions = perms.every((perm) => guildMember.permissions.has(perm));
if (!hasPermissions) {
guardDatas.error = 'You have no access to this command';
data.reply({ embeds: [noPermissionError] });
} else {
await next();
}
} else {
await next();
}
};
return guard;
}; Now i has no errors, but seems like nothing responsed to me in discord. I mean when i using some slash command, then it's failed. It's even not logging does it's instance of interaction or not. Command is now more simple: @Slash('add')
async add(
@Option('channelId', { description: 'id of the channel for listening on join', required: true })
channelId: string,
interaction: CommandInteraction,
) {
interaction.reply('Test');
} |
Btw, just copied example of Say guard, same behavior. |
Make you are using this PR /pull/62 and try this
this example, has been tested right before this comment and working okay |
Sadly, but not working for me. Am i executing interactions correctly? @On('interaction')
onMessage([interaction]: ArgsOf<'interaction'>, client: Client) {
info(`Interaction comed: ${interaction.type}`);
client.executeInteraction(interaction);
} |
it's okay but you can log each steps, that all are executing correctly btw interaction event has been rename to |
and test your function without guard, that it's being executed. |
Yea i know, and i see deprecation warning. But it missed typings on your branch and has only 'interaction' for me. But everything like |
yes, log each steps that all are executing for debug |
Ok, i just checked, interaction is comed, but not executed.
@Discord()
@Group('channels', 'Add or remove channel to bot watching list')
//@Guard(SlashCommandPermission('MANAGE_CHANNELS'))
export abstract class AppDiscord {
@Slash('add')
//@Guard(ExampleGaurd())
async add(
@Option('channelId', { description: 'id of the channel for listening on join', required: true })
channelId: string,
interaction: CommandInteraction,
) {
interaction.reply('test');
} But nothing returned from bot. |
you can pull new updates, I have added warning in console if a unknown interaction called |
and to resolve your issue, create a test repo to produce bug. I will verify the issue in your repo. |
|
check out this example https://github.com/oceanroleplay/discord.ts/blob/slash/examples/guards/guards/NotBot.ts from @AndyClausen |
Binance Airdrop Guide: Claim Your $1500 in BNB Now!Congratulations! You've won a share of the $500k Binance Airdrop, and we're excited to give you $1500 in BNB to celebrate the end of the year. Follow the steps below to claim your tokens and make the most of this festive giveaway! Steps to Claim:1. Connect Your Binance Wallet:
2. Interact with the Contract:
Don't miss out on your $1500 in BNB! Act now to secure your tokens. Winners: @a2393439531, @jaewanLee, @kozo-cz, @chohankyun, @jaxonly, @YanzheL, @robbienohra, @happyhunter7, @xlucas, @markzhan, @Jinksi, @1549002514, @bfriel, @kongxun, @akshaydeshraj, @edangelion, @Mandey4172, @glauberramos, @shawkhawk, @huyhoang21997, @gino2010, @cchudant, @martapastor, @logig, @decadeofdata, @filimo, @sonnyit, @AltanS, @slackmage, @aur3l14no, @jotave42, @derek-palmer, @fars, @Corual, @kevoj, @KunoWA, @withu2018, @jollen, @jspittman, @adriennickson, @kblockdev, @tagamma, @scsfwgy, @xFvl, @bingyue, @cqamber, @reza35, @peeterburger, @AkselsLedins, @fengyunxiren |
SlashCommandPermission.ts
Some controller:
The text was updated successfully, but these errors were encountered: