简体   繁体   English

我需要帮助注册全球所有公会,有人可以帮助我吗?

[英]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.

相关问题 有人可以协助我制作以下动画吗 - Can someone assist me in creating the following animation 我在查找此textarea值是iframe还是简单文本时遇到问题。 有人能帮我吗? - I'm facing an issue to find if this textarea value is iframe or simple text. Can someone help me? 有人可以帮我解决这个语法吗? - Can someone help me with this syntax? 有人可以帮我解决这个算法吗? - Can someone help me with this algorithm? 有人可以帮助我解决这个错误吗? - can someone help me with this error? 有人可以帮我解决这个问题吗? - Can someone help me fix this? 有人可以帮助我解决错误吗? - Can someone help me with an err? 当我使用 Angularjs 的 ng-repeat 时,我需要防止对特定“类”的迭代。 有人能帮我吗? - I need to prevent iteration over a specific “class” while I use ng-repeat by Angularjs. can someone help me? 有人可以帮我解决我的前端脚本问题吗? 我需要知道这是否是编写此脚本的唯一方法,或者是否有更好的方法 - Can someone help me with my frontend script issue? I need to know if this is the only way to code this script or if there are better ways 我收到 ajax 获取请求的问题有人可以帮我吗? - I get a problem with ajax get request can someone help me?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM