simpler/universal bot-user-id access

This commit is contained in:
Baipyrus 2024-04-29 10:30:50 +02:00
parent 09f9593a5c
commit 3b1d640612
4 changed files with 4 additions and 13 deletions

View File

@ -6,7 +6,7 @@ export const name = Events.MessageCreate;
/** @param {Message} message */
export async function execute(message) {
// Ignore direct messages and own messages
if (!message.inGuild() || message.author.id === process.env.CLIENT) return;
if (!message.inGuild() || message.author.id === message.client.user.id) return;
// Split message content into words
const words = message.content

View File

@ -1,8 +1,5 @@
import { Events, MessageReaction, User } from 'discord.js';
import { Messages, RoleEmojiPairs } from '../../database.js';
import { config } from 'dotenv';
config();
export const name = Events.MessageReactionAdd;
/**
@ -10,7 +7,7 @@ export const name = Events.MessageReactionAdd;
* @param {User} user
*/
export async function execute(reaction, user) {
if (user.id === process.env.CLIENT) return;
if (user.id === user.client.user.id) return;
// Get message
const msgID = reaction.message.id;

View File

@ -1,8 +1,5 @@
import { Events, MessageReaction, User } from 'discord.js';
import { Messages, RoleEmojiPairs } from '../../database.js';
import { config } from 'dotenv';
config();
export const name = Events.MessageReactionRemove;
/**
@ -10,7 +7,7 @@ export const name = Events.MessageReactionRemove;
* @param {User} user
*/
export async function execute(reaction, user) {
if (user.id === process.env.CLIENT) return;
if (user.id === user.client.user.id) return;
// Get message
const msgID = reaction.message.id;

View File

@ -1,13 +1,10 @@
import { ChatInputCommandInteraction, ContextMenuCommandInteraction, Role } from 'discord.js';
import { Messages, RoleEmojiPairs, Guilds } from './database.js';
import { readdir } from 'fs/promises';
import { config } from 'dotenv';
import { Op } from 'sequelize';
import { join } from 'path';
import Module from 'module';
config();
/**
* Main logic of the different 'Self Roles remove' commands to remove the functionality from a `Message`.
* @param {(ChatInputCommandInteraction|ContextMenuCommandInteraction)} interaction The interaction related to this command.
@ -90,7 +87,7 @@ const saveMessageData = async (id, role, emoji) => {
* @param {string} emoji Either a unicode emoji or a string representation in Discord custom emoji format.
*/
const editMessage = async (message, role, emoji) => {
if (message.author.id !== process.env.CLIENT) return;
if (message.author.id !== message.client.user.id) return;
// Find out whether to pad message or already present
let padding = '\n';