generated from Baipyrus/DiscordJS-Template
bugfix: add role to database like member_roles
This commit is contained in:
parent
3b1d640612
commit
4035e4b40d
12
shared.js
12
shared.js
@ -1,5 +1,5 @@
|
|||||||
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, Roles } from './database.js';
|
||||||
import { readdir } from 'fs/promises';
|
import { readdir } from 'fs/promises';
|
||||||
import { Op } from 'sequelize';
|
import { Op } from 'sequelize';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
@ -71,6 +71,16 @@ const saveMessageData = async (id, role, emoji) => {
|
|||||||
defaults: guildData
|
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
|
// Create database entry for pair
|
||||||
await RoleEmojiPairs.create({
|
await RoleEmojiPairs.create({
|
||||||
message: id,
|
message: id,
|
||||||
|
Loading…
Reference in New Issue
Block a user