Im making a discord bot that sends a user that sends a message to every member in the server. It worked a while ago but without chaning anything it suddenly stopped working. Not to sound egotistical but i doubt its anything with my code and more just something i forgot to setup but in the case its me, i've sent the code below
client.on("message", message => {
const { guild } = message
console.log(guild)
i've tried to get the guild at different spots in the process but it doesn't seem to work. I've looked at the docs but that didn't help a lot. They also just use message.guild
. I tried just printing the message
object and it returns
Message {
channel: DMChannel {
type: 'dm',
deleted: false,
id: '795038485052522546',
recipient: User {
id: '358317103834726401',
system: null,
locale: null,
flags: [UserFlags],
username: 'T3CH',
bot: false,
discriminator: '6969',
avatar: 'a_578305126220c42a2de15defb32ad2b6',
lastMessageID: null,
lastMessageChannelID: null
},
lastMessageID: '797538660227481650',
lastPinTimestamp: null,
messages: MessageManager {
cacheType: [class LimitedCollection extends Collection],
cache: [LimitedCollection [Map]],
channel: [Circular]
},
_typing: Map {}
},
deleted: false,
id: '797538660227481650',
type: 'DEFAULT',
system: false,
content: 'There was an error finding the guild',
author: ClientUser {
id: '764065338592591873',
system: null,
locale: null,
flags: UserFlags { bitfield: 0 },
username: 'Greg Michaelson',
bot: true,
discriminator: '6184',
avatar: '4fc90843924c172c60c126c0284e9561',
lastMessageID: '797538660227481650',
lastMessageChannelID: '795038485052522546',
verified: true,
mfaEnabled: true,
_typing: Map {}
},
pinned: false,
nonce: null,
embeds: [],
attachments: Collection [Map] {},
createdTimestamp: 1610218434150,
editedTimestamp: 0,
reactions: ReactionManager {
cacheType: [class Collection extends Collection],
cache: Collection [Map] {},
message: [Circular]
},
mentions: MessageMentions {
everyone: false,
users: Collection [Map] {},
roles: Collection [Map] {},
_members: null,
_channels: null,
crosspostedChannels: Collection [Map] {}
},
webhookID: null,
application: null,
activity: null,
_edits: [],
flags: MessageFlags { bitfield: 0 },
reference: null
}
Thanks in advance
question from:
https://stackoverflow.com/questions/65646517/message-guild-returns-null-in-discordjs