From efb431ef3a4cb8b7befa1712e5361ad54d75d44d Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Sat, 16 Dec 2023 16:50:26 +0000 Subject: [PATCH] Fix nickname change event not working (#385) # Description Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. - Fix the nickname changed event not working - This was due to the default value not being set because of a typo - Update the client to allow partials for guild members #353 ## Type of change Please delete options that are not relevant. - [x] Bug fix (non-breaking change which fixes an issue) # How Has This Been Tested? Please describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details to your test configuration. - This has been tested locally by making sure the nickname change event fires when expected # Checklist - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that provde my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/vylbot-app/pulls/385 Reviewed-by: VylpesTester Co-authored-by: Ethan Lane Co-committed-by: Ethan Lane --- src/client/client.ts | 6 +++--- src/client/util.ts | 2 +- src/constants/DefaultValues.ts | 12 ++++++------ src/vylbot.ts | 5 ++++- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/client/client.ts b/src/client/client.ts index d544ec7..9e8f4ef 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -1,4 +1,4 @@ -import { Client } from "discord.js"; +import { Client, Partials } from "discord.js"; import * as dotenv from "dotenv"; import { createConnection } from "typeorm"; import { EventType } from "../constants/EventType"; @@ -25,8 +25,8 @@ export class CoreClient extends Client { return this._eventItems; } - constructor(intents: number[]) { - super({ intents: intents }); + constructor(intents: number[], partials: Partials[]) { + super({ intents: intents, partials: partials }); dotenv.config(); CoreClient._commandItems = []; diff --git a/src/client/util.ts b/src/client/util.ts index a9c2bad..e367324 100644 --- a/src/client/util.ts +++ b/src/client/util.ts @@ -37,7 +37,7 @@ export class Util { .flatMap(x => x.Command.CommandBuilder); if (!client.guilds.cache.has(guild)) continue; - + rest.put( Routes.applicationGuildCommands(process.env.BOT_CLIENTID!, guild), { diff --git a/src/constants/DefaultValues.ts b/src/constants/DefaultValues.ts index 3f5ba09..8608fbb 100644 --- a/src/constants/DefaultValues.ts +++ b/src/constants/DefaultValues.ts @@ -6,7 +6,7 @@ export default class DefaultValues { this.SetValues(); const res = this.values.find(x => x.Key == key); - + if (!res) { return undefined; } @@ -46,18 +46,18 @@ export default class DefaultValues { // Event this.values.push({ Key: "event.message.delete.enabled", Value: "false" }); this.values.push({ Key: "event.message.delete.channel", Value: "message-logs" }); - + this.values.push({ Key: "event.message.update.enabled", Value: "false" }); this.values.push({ Key: "event.message.update.channel", Value: "message-logs" }); - + this.values.push({ Key: "event.member.add.enabled", Value: "false" }); this.values.push({ Key: "event.member.add.channel", Value: "member-logs" }); - + this.values.push({ Key: "event.member.remove.enabled", Value: "false" }); this.values.push({ Key: "event.member.remove.channel", Value: "member-logs" }); - + this.values.push({ Key: "event.member.update.enabled", Value: "false" }); - this.values.push({ Key: "event.member.remove.channel", Value: "member-logs" }); + this.values.push({ Key: "event.member.update.channel", Value: "member-logs" }); } } diff --git a/src/vylbot.ts b/src/vylbot.ts index 668c8e5..ad30c48 100644 --- a/src/vylbot.ts +++ b/src/vylbot.ts @@ -1,7 +1,7 @@ import { CoreClient } from "./client/client"; import * as dotenv from "dotenv"; import registry from "./registry"; -import { IntentsBitField } from "discord.js"; +import { IntentsBitField, Partials } from "discord.js"; dotenv.config(); @@ -30,6 +30,9 @@ const client = new CoreClient([ IntentsBitField.Flags.GuildMessages, IntentsBitField.Flags.GuildMembers, IntentsBitField.Flags.MessageContent, +], [ + Partials.GuildMember, + Partials.User, ]); registry.RegisterCommands();