import { Model , ModelOptions , QueryContext } from 'objection' ; interface IRole { created_at : Date ; updated_at : Date ; channel : string ; message : string ; emoji : string ; role : string ; guild : string ; emoji_raw : string ; single_use : boolean ; } export default class Role extends Model implements IRole { created_at : Date ; updated_at : Date ; channel : string ; message : string ; emoji : string ; role : string ; guild : string ; emoji_raw : string ; single_use : boolean ; /**
     * Get the name of the table.
     */ static get tableName ( ) : string { return 'roles' ; } param opt param queryContext $beforeUpdate ( opt , queryContext ) { this . updated_at = new Date ( ) ; } param messageID param emojiID param roleID static async doesExist ( messageID , emojiID , roleID ) { const query = await this . query ( ) . where ( 'message' , messageID ) . whereRaw ( '`emoji` COLLATE utf8mb4_bin = ?' , [ emojiID ] ) . where ( 'role' , roleID ) . count ( '*' ) . as ( 'count' ) . execute ( ) ; const count = query [ 0 ] [ 'count' ] ; return count > 0 ; } param channelID param messageID param emojiID param roleID param guildID param emojiRaw param singleUse static async createReactionRole ( channelID , messageID , emojiID , roleID , guildID , emojiRaw , singleUse = false ) { await this . query ( ) . insert ( { channel : channelID , message : messageID , emoji : emojiID , role : roleID , guild : guildID , emoji_raw : emojiRaw , single_use : singleUse , } ) ; } param messageID param emojiID param roleID param singleUse static async updateRoleSingleUse ( messageID , emojiID , roleID , singleUse ) { await this . query ( ) . where ( 'message' , messageID ) . whereRaw ( '`emoji` COLLATE utf8mb4_bin = ?' , [ emojiID ] ) . where ( 'role' , roleID ) . update ( { single_use : singleUse } ) ; } param messageID param emojiID returns static async deleteReactionRole ( messageID , emojiID ) { return this . query ( ) . where ( 'message' , messageID ) . whereRaw ( '`emoji` COLLATE utf8mb4_bin = ?' , [ emojiID ] ) . del ( ) ; } param guildID returns static async deleteGuildRoles ( guildID ) { return this . query ( ) . where ( 'guild' , guildID ) . del ( ) ; } param channelID returns static async deleteChannelRoles ( channelID ) { return this . query ( ) . where ( 'channel' , channelID ) . del ( ) ; } param messageID returns static async deleteMessageRoles ( messageID ) { return this . query ( ) . where ( 'message' , messageID ) . del ( ) ; } param guildID static async getGuildRoles ( guildID ) { return this . query ( ) . where ( 'guild' , guildID ) . select ( ) ; } /**
     * Get all rows from the database.
     */ static async all ( ) { return this . query ( ) . select ( ) ; } }