DiscordJS-Example/models/roleEmojiPairs.js

43 lines
1.0 KiB
JavaScript

import { DataTypes, Deferrable, Sequelize } from 'sequelize';
/**
* @typedef {Object} RoleEmojiPair
* @property {string} id A universally unique id, generated by sequelize.
* @property {string} message A Discord message ID as a foreign key reference.
* @property {string} role A Discord role ID.
* @property {string} emoji Either a unicode emoji or a string representation in Discord custom emoji format.
*/
/**
* The definition of the `RoleEmojiPairs` table in the database.
* @param {Sequelize} sequelize
*/
export default function (sequelize) {
return sequelize.define('RoleEmojiPairs', {
id: {
defaultValue: DataTypes.UUIDV4,
type: DataTypes.UUID,
primaryKey: true
},
message: {
type: DataTypes.STRING,
references: {
deferrable: Deferrable.INITIALLY_IMMEDIATE,
model: 'Messages',
key: 'id'
}
},
role: {
type: DataTypes.STRING,
references: {
deferrable: Deferrable.INITIALLY_IMMEDIATE,
model: 'Roles',
key: 'id'
}
},
emoji: {
type: DataTypes.STRING
}
});
}