bugfix: add role to database like member_roles

This commit is contained in:
Baipyrus 2024-04-30 09:56:23 +02:00
parent 3b1d640612
commit 4035e4b40d

View File

@ -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,