mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-05-18 17:14:15 +02:00
fix(arabot): adding sus note to user who left server
This commit is contained in:
parent
d8c91fd39b
commit
46ef2fd8e2
@ -219,26 +219,11 @@ export class SusCommand extends Subcommand {
|
|||||||
success: false,
|
success: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get GuildMember for user to add a sus note for
|
|
||||||
let member = guild.members.cache.get(user.id);
|
|
||||||
|
|
||||||
// Checks if Member was not found in cache
|
|
||||||
if (member === undefined) {
|
|
||||||
// Fetches Member from API call to Discord
|
|
||||||
member = await guild.members.fetch(user.id);
|
|
||||||
if (member === undefined) {
|
|
||||||
info.message = 'Error fetching user';
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the data to the database
|
// Add the data to the database
|
||||||
await addSusNoteDB(user.id, mod.id, note);
|
await addSusNoteDB(user.id, mod.id, note);
|
||||||
|
|
||||||
// Give the user the sus role they don't already have the sus note
|
// Gives the sus role to the user
|
||||||
if (!member.roles.cache.has(IDs.roles.restrictions.sus)) {
|
await this.addSusRole(user, guild);
|
||||||
await member.roles.add(IDs.roles.restrictions.sus);
|
|
||||||
}
|
|
||||||
|
|
||||||
info.message = `Added the sus note for ${user}: ${note}`;
|
info.message = `Added the sus note for ${user}: ${note}`;
|
||||||
info.success = true;
|
info.success = true;
|
||||||
@ -278,6 +263,26 @@ export class SusCommand extends Subcommand {
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async addSusRole(user: User, guild: Guild) {
|
||||||
|
// Get GuildMember for user to add a sus note for
|
||||||
|
let member = guild.members.cache.get(user.id);
|
||||||
|
|
||||||
|
// Checks if Member was not found in cache
|
||||||
|
if (member === undefined) {
|
||||||
|
// Fetches Member from API call to Discord
|
||||||
|
member = await guild.members.fetch(user.id).catch(() => undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (member === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Give the user the sus role they don't already have the sus note
|
||||||
|
if (!member.roles.cache.has(IDs.roles.restrictions.sus)) {
|
||||||
|
await member.roles.add(IDs.roles.restrictions.sus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async listNote(interaction: Subcommand.ChatInputCommandInteraction) {
|
public async listNote(interaction: Subcommand.ChatInputCommandInteraction) {
|
||||||
// Get the arguments
|
// Get the arguments
|
||||||
const user = interaction.options.getUser('user', true);
|
const user = interaction.options.getUser('user', true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user