简体   繁体   English

需要帮助{discord bot}}

[英]need help {discord bot}}

I want to start my Bot but it dont work and i tried already the most things but nothing worked for me.我想启动我的 Bot,但它不起作用,我已经尝试了最多的东西,但对我没有任何效果。 I hope you can help me我希望你能帮帮我

The Code:编码:

client.on('ready', async () => {
log.success(`Authenticated as ${client.user.tag}`);
client.user.setPresence({
    activity: {
        name: env.PRESENCE_ACTIVITY,
        type: env.PRESENCE_TYPE.toUpperCase()
    }
})
if (client.guilds.cache.get(env.GUILD_ID).member(client.user).hasPermission('ADMINISTRATOR', false)) {
    log.success('Bot has the \'ADMINISTRATOR\' permission');
} else log.warn('Bot does not have \'ADMINISTRATOR\' permission');
client.guilds.cache.get(env.GUILD_ID).roles.fetch().then((roles) => {
    purchasedRole = roles.cache.get(env.PURCHASED_ROLE_ID);
});

}); });

Error:错误:

TypeError: Cannot read properties of undefined (reading 'member')
at Client.<anonymous> (C:\Users\User\Desktop\Discord-Bot\index.js:308:46)
at Client.emit (node:events:527:28)
at WebSocketManager.triggerClientReady (C:\Users\User\Desktop\Discord-Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:431:17)
at WebSocketManager.checkShardsReady (C:\Users\User\Desktop\Discord-Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:415:10)
at WebSocketShard.<anonymous> (C:\Users\User\Desktop\Discord-Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:197:14)
at WebSocketShard.emit (node:events:527:28)
at WebSocketShard.checkReady (C:\Users\User\Desktop\Discord-Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:475:12)
at WebSocketShard.onPacket (C:\Users\User\Desktop\Discord-Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:447:16)
at WebSocketShard.onMessage (C:\Users\User\Desktop\Discord-Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\User\Desktop\Discord-Bot\node_modules\ws\lib\event-target.js:132:16)

Can someone help?有人可以帮忙吗?

You have a typo in client.guilds.cache.get(env.GUILD_ID).member(client.user) .您在client.guilds.cache.get(env.GUILD_ID).member(client.user)中有错字。

Its not member its the plural members as you can see here它不是member ,它是复数members ,你可以在这里看到

I don't know if client.user works here so maybe try client.user.id我不知道client.user是否在这里工作,所以也许试试client.user.id

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM