Compare commits

...

3 Commits

Author SHA1 Message Date
3b1d640612 simpler/universal bot-user-id access 2024-04-29 10:30:50 +02:00
09f9593a5c better typing 2024-04-29 10:30:39 +02:00
daf3767490 expand readme on quirks of behavior 2024-04-29 10:29:05 +02:00
6 changed files with 8 additions and 14 deletions

View File

@ -249,7 +249,8 @@ Registered roles will automatically be assigned to new members
## Quirks/Bugs ## Quirks/Bugs
None - Custom VC not working in global space
- Categories with Custom VC channel in them need explicit permissions
## Changes ## Changes

View File

@ -1,5 +1,6 @@
import { import {
ChannelType, ChannelType,
GuildChannel,
PermissionFlagsBits, PermissionFlagsBits,
SlashCommandBuilder, SlashCommandBuilder,
ChatInputCommandInteraction ChatInputCommandInteraction
@ -90,6 +91,7 @@ export async function execute(interaction) {
} }
case 'register': { case 'register': {
// Get channel id from user input // Get channel id from user input
/** @type {GuildChannel} */
const { id } = options.getChannel('channel'); const { id } = options.getChannel('channel');
step = 'save'; step = 'save';

View File

@ -6,7 +6,7 @@ export const name = Events.MessageCreate;
/** @param {Message} message */ /** @param {Message} message */
export async function execute(message) { export async function execute(message) {
// Ignore direct messages and own messages // 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 // Split message content into words
const words = message.content const words = message.content

View File

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

View File

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

View File

@ -1,13 +1,10 @@
import { ChatInputCommandInteraction, ContextMenuCommandInteraction, Role } from 'discord.js'; import { ChatInputCommandInteraction, ContextMenuCommandInteraction, Role } from 'discord.js';
import { Messages, RoleEmojiPairs, Guilds } from './database.js'; import { Messages, RoleEmojiPairs, Guilds } from './database.js';
import { readdir } from 'fs/promises'; import { readdir } from 'fs/promises';
import { config } from 'dotenv';
import { Op } from 'sequelize'; import { Op } from 'sequelize';
import { join } from 'path'; import { join } from 'path';
import Module from 'module'; import Module from 'module';
config();
/** /**
* Main logic of the different 'Self Roles remove' commands to remove the functionality from a `Message`. * 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. * @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. * @param {string} emoji Either a unicode emoji or a string representation in Discord custom emoji format.
*/ */
const editMessage = async (message, role, emoji) => { 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 // Find out whether to pad message or already present
let padding = '\n'; let padding = '\n';