简体   繁体   English

类型错误:无法读取未定义的属性(读取“设置”)discord.js v13 斜杠命令处理程序

[英]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();还定义了SlashComanndsArraySlashCommand并且对于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 中的东西
  • Use Guild#commands instead.请改用Guild#commands
Mainguild.commands
  • Your 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.

相关问题 TypeError:无法在 discord.js v13 中读取未定义的属性(读取“路径”) - TypeError: Cannot read properties of undefined (reading 'path') in discord.js v13 discord.js v13 - 类型错误:无法读取未定义的属性(读取“正常运行时间”) - discord.js v13 - TypeError: Cannot read properties of undefined (reading 'uptime') discord.js v13 类型错误:无法读取未定义的属性(读取“存在”) - discord.js v13 TypeError: Cannot read properties of undefined (reading 'presence') 类型错误:无法读取未定义的属性(读取“获取”)Discord.js v13 - TypeError: Cannot read properties of undefined (reading 'fetch') Discord.js v13 discord.js v13 permissions.has() function 不工作(TypeError: Cannot read properties of undefined (reading 'has')) - discord.js v13 permissions.has() function not working (TypeError: Cannot read properties of undefined (reading 'has')) 无法读取未定义的属性(读取“权限”)。 | Discord.js v13 - Cannot read properties of undefined (reading 'permissions'). | Discord.js v13 Discord.js v13 无法读取属性 o 未定义的读取发送 - Discord.js v13 cannot read properties o undefined reading send 无法读取未定义的属性(读取“发送”)(Discord.js v13) - Cannot read properties of undefined (reading 'send') (Discord.js v13) 无法在 Discord.js V13 中读取未定义的属性(读取“删除”) - Cannot read properties of undefined (reading 'delete') in Discord.js V13 TypeError:无法读取未定义的属性(读取“toJSON”)- Discord.js 斜杠命令 - TypeError: Cannot read properties of undefined (reading 'toJSON') - Discord.js slash commands
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM