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 toolkit3mo 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
Zerls3mo 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.3mo ago
does it need partial
Unicorn.
Unicorn.3mo ago
No description
Zerls
Zerls3mo ago
you aren't doing this in the code you gave us
Unicorn.
Unicorn.3mo ago
:Thinkeng: ?
Zerls
Zerls3mo ago
you aren't doing channel.isTextBased() in the code above
Unicorn.
Unicorn.3mo ago
where to add this that i could do
Zerls
Zerls3mo ago
well this error isn't coming from the code you had sent above
Unicorn.
Unicorn.3mo 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
Zerls3mo ago
ah it's happening internally @Unicorn. can you log message also what intents do you have?
Unicorn.
Unicorn.3mo ago
it also show this
TÆMBØ
TÆMBØ3mo ago
Can you run npm ls discord.js?
Unicorn.
Unicorn.3mo ago
i tried console log message
Zerls
Zerls3mo ago
I just realised that won't work because the error occurs before djs emits the interactionCreate event
Unicorn.
Unicorn.3mo ago
No description
TÆMBØ
TÆMBØ3mo ago
Update
Unicorn.
Unicorn.3mo ago
update handler oh i'll try
TÆMBØ
TÆMBØ3mo 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.3mo ago
oh thx it works