[英]I'm in need of help registering for all guilds globally, can someone assist me?
I'm looking to register for all guilds globally instead of registering for just my guild ID, just so I can use slash commands in my friend's server (plus any other server it's in), yet I don't know how.我希望在全球范围内注册所有公会,而不是只注册我的公会 ID,这样我就可以在我朋友的服务器(以及它所在的任何其他服务器)中使用斜杠命令,但我不知道如何。 I'm a bit new to discord.js.
我对 discord.js 有点陌生。
I was wondering if someone could help me register for all guilds globally...我想知道是否有人可以帮我注册全球所有公会...
Extra information - I'm following reconlx's Discord.js v13 tutorials.额外信息 - 我正在关注 reconlx 的 Discord.js v13 教程。
This is the part of my code which I need help looking at and modifying.这是我的代码的一部分,我需要帮助查看和修改。 There's a line in his command handler talking about registering for all guilds at
await client.application.commands.set(arrayOfSlashCommands);
在他的命令处理程序中有一行是关于在
await client.application.commands.set(arrayOfSlashCommands);
处注册所有公会的。 , yet I'm not sure what it means... ,但我不确定这是什么意思......
client.on("ready", async () => {
// Register for a single guild
const guild = client.guilds.cache.get("938823675535319050")
await guild.commands.set(arrayOfSlashCommands).then((cmd) => {
const getRoles = (commandName) => {
const permissions = arrayOfSlashCommands.find(
(x) => x.name === commandName
).userPermissions;
if(!permissions) return null;
return guild.roles.cache.filter(
(x) => x.permissions.has(permissions) && !x.managed
);
};
const fullPermissions = cmd.reduce((accumulator, x) => {
const roles = getRoles(x.name);
if(!roles) return accumulator;
const permissions = roles.reduce((a, v) => {
return [
...a,
{
id: v.id,
type: 'ROLE',
permission: true,
},
];
}, []);
return [
...accumulator,
{
id: x.id,
permissions,
},
];
}, []);
guild.commands.permissions.set({ fullPermissions });
});
// Register for all the guilds the bot is in
// await client.application.commands.set(arrayOfSlashCommands);
});
Looking forward to some solutions, if you could assist, it would help a lot.期待一些解决方案,如果你能提供帮助,那将有很大帮助。
You can register global commands using the Client.application.commands.set()
method, passing in an Array of ApplicationCommandDataResolvables
into the method.您可以使用
Client.application.commands.set()
方法注册全局命令,将ApplicationCommandDataResolvables
数组传入该方法。 However, please be aware a caveat of global commands is that they take up to an hour for changes to reflect across Discord.但是,请注意全局命令的一个警告是它们最多需要一个小时才能在 Discord 中反映更改。
See this:看到这个:
client.application.commands.set(commands)
// ^^^ ^^^^^^^^
// Client is your Discord.Client Commands is the list of commands
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.