[英]TypeError: Cannot read properties of undefined (reading 'set') discord.js v13 slash commands handler
I am creating a Slash commands handler when i run the bot i get this error: Mainguild.SlashCommands.set(SlashComanndsArray).then(async (SlashCommand) => { TypeError: Cannot read properties of undefined (reading 'set')
this is the code:当我运行机器人时我正在创建一个 Slash 命令处理程序我得到这个错误:
Mainguild.SlashCommands.set(SlashComanndsArray).then(async (SlashCommand) => { TypeError: Cannot read properties of undefined (reading 'set')
这是代码:
client.on("ready", async () => {
const Mainguild = await client.guilds.cache.get("926674245357039657");
Mainguild.SlashCommands.set(SlashComanndsArray).then(async (SlashComanndsArray) => {
const Roles = (SlashCommandName) => {
const cmdPerms = SlashComanndsArray.find((c) => c.name === SlashCommandName).permission;
if(!cmdPerms) return null;
return Mainguild.roles.cache.filter((r) => r.permissions.has(cmdPerms));
};
const FullPermissions = SlashCommand.reduce((accumulator, r) => {
const roles = Roles(r.name);
if(!roles) return accumulator;
const permissions = roles.reduce((a, r) => {
return [...a, {id: r.id, type: "ROLE", permission: true}];
}, []);
return [...accumulator, {id: r.id, permissions}];
}, []);
await Mainguild.SlashCommands.permissions.set({ FullPermissions });
});
})
}
also SlashComanndsArray
, SlashCommand
are defined and for the SlashCommands
is a collection that i created id index.js with client.SlashCommands = new Collection();
还定义了
SlashComanndsArray
, SlashCommand
并且对于SlashCommands
是我创建的集合 id index.js with client.SlashCommands = new Collection();
the full code: https://srcb.in/BX1Ko4LuXd the index.js: https://srcb.in/qFC57vTaSn完整代码: https://srcb.in/BX1Ko4LuXd index.js: https://srcb.in/qFC57vTaSn
Mainguild.SlashCommands
is obviously undefined because Guild.SlashCommands
is not a thing in discord.js Mainguild.SlashCommands
显然是未定义的,因为Guild.SlashCommands
不是 discord.js 中的东西Mainguild.commands
client.SlashCommands
is limited to your client
.client.SlashCommands
仅限于您的client
。 You cannot use it with a Guild
.Guild
一起使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.