From 4035e4b40d3285911fd9c95d143cfc92d1a8ebea Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Tue, 30 Apr 2024 09:56:23 +0200 Subject: [PATCH] bugfix: add role to database like member_roles --- shared.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/shared.js b/shared.js index a6f574e..5c65308 100644 --- a/shared.js +++ b/shared.js @@ -1,5 +1,5 @@ import { ChatInputCommandInteraction, ContextMenuCommandInteraction, Role } from 'discord.js'; -import { Messages, RoleEmojiPairs, Guilds } from './database.js'; +import { Messages, RoleEmojiPairs, Guilds, Roles } from './database.js'; import { readdir } from 'fs/promises'; import { Op } from 'sequelize'; import { join } from 'path'; @@ -71,6 +71,16 @@ const saveMessageData = async (id, role, emoji) => { defaults: guildData }); + // Create role if not exists + const roleData = { + id: role.id, + guild: guildData.id + }; + await Roles.findOrCreate({ + where: roleData, + defaults: roleData + }); + // Create database entry for pair await RoleEmojiPairs.create({ message: id,