Unable to get member data from users that have left / kicked

Hi, I am trying to get data from members who have left the discord server or have been kicked. But I keep getting undefined errors and I am unsure why here is my code. This only happen in sapphire
@ApplyOptions<Listener.Options>({ event: Events.GuildMemberRemove, name: 'Handle Guild Member Kick/Leave' })
export class MemberRemove extends Listener {
public async run(guild: Guild, member: PartialGuildMember) {
console.log(member); }
}
@ApplyOptions<Listener.Options>({ event: Events.GuildMemberRemove, name: 'Handle Guild Member Kick/Leave' })
export class MemberRemove extends Listener {
public async run(guild: Guild, member: PartialGuildMember) {
console.log(member); }
}
Solution:
1. Unrelated to Sapphire 2. You're implementing the event parameters incorrectly, see https://discord.js.org/#/docs/discord.js/main/class/Client?scrollTo=e-guildMemberRemove...
J
jordanmckoy436d ago
S
Sawako436d ago
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
J
jordanmckoy435d ago
Thank you also I def didn’t get timed out for calling my self dumb 😂 Sadly this did not work,
index.ts
export const client = new SapphireClient({
defaultPrefix: '!',
regexPrefix: /^(hey +)?bot[,! ]/i,
caseInsensitiveCommands: true,
logger: {
level: LogLevel.Debug
},
shards: 'auto',
intents: [
GatewayIntentBits.DirectMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildBans,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent
],
partials: [Partials.Channel, Partials.GuildMember, Partials.Message, Partials.Reaction, Partials.User],
loadMessageCommandListeners: true
});
index.ts
export const client = new SapphireClient({
defaultPrefix: '!',
regexPrefix: /^(hey +)?bot[,! ]/i,
caseInsensitiveCommands: true,
logger: {
level: LogLevel.Debug
},
shards: 'auto',
intents: [
GatewayIntentBits.DirectMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildBans,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent
],
partials: [Partials.Channel, Partials.GuildMember, Partials.Message, Partials.Reaction, Partials.User],
loadMessageCommandListeners: true
});
event.ts
@ApplyOptions<Listener.Options>({ event: Events.GuildMemberRemove, name: 'Handle Guild Member Kick/Leave' })
export class MemberRemove extends Listener {
public async run(guild: Guild, member: GuildMember) {
if (member.partial) {
const memberPartial = await member.fetch();
console.log(memberPartial.id)
}
}
}
event.ts
@ApplyOptions<Listener.Options>({ event: Events.GuildMemberRemove, name: 'Handle Guild Member Kick/Leave' })
export class MemberRemove extends Listener {
public async run(guild: Guild, member: GuildMember) {
if (member.partial) {
const memberPartial = await member.fetch();
console.log(memberPartial.id)
}
}
}
I also tried to pass in the PartialGuildMember Type, PartialUser Type and User Type to the event listener it self /listeners/events/member.js" TypeError: Cannot read properties of undefined (reading 'partial')
J
jordanmckoy435d ago
My intents are setup
Solution
F
Favna435d ago
1. Unrelated to Sapphire 2. You're implementing the event parameters incorrectly, see https://discord.js.org/#/docs/discord.js/main/class/Client?scrollTo=e-guildMemberRemove
Discord.js
Discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
J
jordanmckoy435d ago
I did not even notice I had the guild parameter there thank you
Want results from more Discord servers?
Add your server
More Posts
Catch all chat input command errors listenerHello ! I tried using the `Events.ChatInputCommandError` listener to catch any errors thrown by the Multiple Clients on one file/instanceI was wondering if its possible to run multiple clients on one file (i.e. .forEach()-ing `new ClientHow to present Slashcommands?How can I present the Slashcommands of my bot in his About Me like for example carl.gg does?Interaction HandlersAm I required to specify to sapphire where my interaction handlers directory is? A `interaction-handbot won't get on and connect to discord.hi, my bot won't turn on. i've coded a lot of bots before with sapphire and they worked just fine, dHow Do I Make a Project in my current Directory?I want to make the proj in `workspaces/DashMate` not like `workspaces/DashMate/${ProjName}`Bot wont go onlinewhen I try to run the script `yarn dev` I get this problemGuildDelete Event somehow gets triggered when I restart my BotI have no idea whats happening but if my bot (docker container) restarts, this notification gets senTypeError: Class extends value undefined is not a constructor or nullHey, newbie here in both TypeScript and Sapphire, and I'm trying to build a command but I'm getting THREAD_CREATE event Listener run method argumentsWhat I want to do: I want to inspect the id of the parent channel where the thread was created. TheCommand info command issueI have a command info command, but when I try to get information on a command called "flags" it retuawait args.pick("member");how to enable this? https://discord.com/channels/737141877803057244/737142071319855105/107804884825Command info command issueI have a command info command, but when I try to get information on a command called "flags" it retuRunning in productionHey! What's the recommended method for starting up a node app in production? Specifically for DiscorspeakerName translation in FFXIVIpcChatHello everyone, I'm using ffxiv-pcap to read chat messages using the Sapphire Struct for chat messagClearing registered slash commandsHello 👋 I would like to know if there's a system provided by Sapphire to automatically clear previDocker being goofyI have no idea why Docker is being all goofy, it's saying that my discord token is invalid, but it'sReferenceError: [ENV] BOT_OWNER_IDS - The key must be an array, but is empty or undefined.I am using `@skyra/env-utilities` and when I start up my bot, I get the error reported in the title How can I turn a joinedTimestamp into this Discord TimestampThe one that automatically shows you like how long ago this timestamp wasHow to use `@sapphire/shapeshift ` dateValid & stringRegexI have a slash command that needs to take in a date input in the format of `YYYY-MM-DD`. I want to