contextmenubuilder

const { ContextMenuCommandBuilder,ApplicationCommandType, PermissionFlagsBits } = require('discord.js');
module.exports = {
data: new ContextMenuCommandBuilder()
.setName('LOA Remove')
.setType(ApplicationCommandType.Message),
async execute(interaction) {
const message = interaction.targetMessage;
const member = message.member
member.roles.add('1187772116767100979');
await interaction.deferReply();
await interaction.deleteReply();
await message.react('');
},
};
const { ContextMenuCommandBuilder,ApplicationCommandType, PermissionFlagsBits } = require('discord.js');
module.exports = {
data: new ContextMenuCommandBuilder()
.setName('LOA Remove')
.setType(ApplicationCommandType.Message),
async execute(interaction) {
const message = interaction.targetMessage;
const member = message.member
member.roles.add('1187772116767100979');
await interaction.deferReply();
await interaction.deleteReply();
await message.react('');
},
};
when using it console log channel.istextbase is not a fuction
20 Replies
d.js toolkit
d.js toolkit9mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Zerls
Zerls9mo ago
i don't see you using isTextBased and .targetMessage can also return an APIMessage so you'll need to check if its in a cached guild
Unicorn.
Unicorn.OP9mo ago
does it need partial
Unicorn.
Unicorn.OP9mo ago
No description
Zerls
Zerls9mo ago
you aren't doing this in the code you gave us
Unicorn.
Unicorn.OP9mo ago
:Thinkeng: ?
Zerls
Zerls9mo ago
you aren't doing channel.isTextBased() in the code above
Unicorn.
Unicorn.OP9mo ago
where to add this that i could do
Zerls
Zerls9mo ago
well this error isn't coming from the code you had sent above
Unicorn.
Unicorn.OP9mo ago
const { Events } = require('discord.js');

module.exports = {
name: Events.InteractionCreate,
async execute(interaction) {
if (interaction.isChatInputCommand()) {
const command = interaction.client.commands.get(interaction.commandName);
if (!command) {
console.error(`未发现有关 ${interaction.commandName} 的命令`);
return;
}
try {
await command.execute(interaction);
} catch (error) {
console.error(`执行 ${interaction.commandName} 失败`);
console.error(error);
}
}
else if (interaction.isMessageContextMenuCommand()) {
const command = interaction.client.commands.get(interaction.commandName);
if (!command) {
console.error(`未发现有关 ${interaction.commandName} 的命令`);
return;
}
try {
await command.execute(interaction);
} catch (error) {
console.error(`执行 ${interaction.commandName} 失败`);
console.error(error);
}
}
else if (interaction.isAutocomplete()) {
const command = interaction.client.commands.get(interaction.commandName);
if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}
try {
command.autocomplete(interaction);
} catch (error) {
console.error(error);
}
}
else return;
},
};
const { Events } = require('discord.js');

module.exports = {
name: Events.InteractionCreate,
async execute(interaction) {
if (interaction.isChatInputCommand()) {
const command = interaction.client.commands.get(interaction.commandName);
if (!command) {
console.error(`未发现有关 ${interaction.commandName} 的命令`);
return;
}
try {
await command.execute(interaction);
} catch (error) {
console.error(`执行 ${interaction.commandName} 失败`);
console.error(error);
}
}
else if (interaction.isMessageContextMenuCommand()) {
const command = interaction.client.commands.get(interaction.commandName);
if (!command) {
console.error(`未发现有关 ${interaction.commandName} 的命令`);
return;
}
try {
await command.execute(interaction);
} catch (error) {
console.error(`执行 ${interaction.commandName} 失败`);
console.error(error);
}
}
else if (interaction.isAutocomplete()) {
const command = interaction.client.commands.get(interaction.commandName);
if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}
try {
command.autocomplete(interaction);
} catch (error) {
console.error(error);
}
}
else return;
},
};
Zerls
Zerls9mo ago
ah it's happening internally @Unicorn. can you log message also what intents do you have?
Unicorn.
Unicorn.OP9mo ago
it also show this
TÆMBØ
TÆMBØ9mo ago
Can you run npm ls discord.js?
Unicorn.
Unicorn.OP9mo ago
i tried console log message
Zerls
Zerls9mo ago
I just realised that won't work because the error occurs before djs emits the interactionCreate event
Unicorn.
Unicorn.OP9mo ago
No description
TÆMBØ
TÆMBØ9mo ago
Update
Unicorn.
Unicorn.OP9mo ago
update handler oh i'll try
TÆMBØ
TÆMBØ9mo ago
Not just that other package, your base package dependency as well 14.7.1 is from a fair bit ago and seems to still include that known channel issue
Unicorn.
Unicorn.OP8mo ago
oh thx it works
Want results from more Discord servers?
Add your server