.fetch()
does not return a value, it returns a Promise
. You are trying to treat myGuild
as if it is a Guild
object, when in reality it is a Promise
that is "promising" you a Guild
object. So how do you obtain the Guild
object? There are two methods: Promises have a .then(value => {})
function which you could use, or you could use the simpler async/await
method.
So here's how that would look in your ready
event:
bot.on("ready", async () => {
let myGuild = await bot.guilds.fetch('759858083718496266'); // Discord server ID
let memberCount = myGuild.memberCount;
let memberCountChannel = await myGuild.channels.fetch('123456789012345678');
//rest of your code
});
Simply add async
before your function declaration, and add await
before each .fetch()
. You need to do this in each of your event handlers; the above is only an example in your ready
event handler.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…