diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-12-27 13:13:10 -0500 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-12-27 13:13:10 -0500 |
commit | 0fa1b2d2a327151f3c9a5c2e28880cf537853302 (patch) | |
tree | 930207facabf2074e4472846b45368412ce0c9ba /src/lib | |
parent | e05f25f4b98cac3c2409cee9a664ab5ea6251467 (diff) | |
download | tanzanite-0fa1b2d2a327151f3c9a5c2e28880cf537853302.tar.gz tanzanite-0fa1b2d2a327151f3c9a5c2e28880cf537853302.tar.bz2 tanzanite-0fa1b2d2a327151f3c9a5c2e28880cf537853302.zip |
remind command
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/extensions/discord-akairo/BushClient.ts | 24 | ||||
-rw-r--r-- | src/lib/index.ts | 2 | ||||
-rw-r--r-- | src/lib/models/Reminder.ts | 77 |
3 files changed, 93 insertions, 10 deletions
diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts index 41ecfaf..7321c17 100644 --- a/src/lib/extensions/discord-akairo/BushClient.ts +++ b/src/lib/extensions/discord-akairo/BushClient.ts @@ -1,3 +1,15 @@ +import { + abbreviatedNumber, + contentWithDuration, + discordEmoji, + duration, + durationSeconds, + globalUser, + messageLink, + permission, + roleWithDuration, + snowflake +} from '#args'; import type { BushApplicationCommand, BushBaseGuildEmojiManager, @@ -35,16 +47,6 @@ import path from 'path'; import readline from 'readline'; import type { Sequelize as SequelizeType } from 'sequelize'; import { fileURLToPath } from 'url'; -import { abbreviatedNumber } from '../../../arguments/abbreviatedNumber.js'; -import { contentWithDuration } from '../../../arguments/contentWithDuration.js'; -import { discordEmoji } from '../../../arguments/discordEmoji.js'; -import { duration } from '../../../arguments/duration.js'; -import { durationSeconds } from '../../../arguments/durationSeconds.js'; -import { globalUser } from '../../../arguments/globalUser.js'; -import { messageLink } from '../../../arguments/messageLink.js'; -import { permission } from '../../../arguments/permission.js'; -import { roleWithDuration } from '../../../arguments/roleWithDuration.js'; -import { snowflake } from '../../../arguments/snowflake.js'; import UpdateCacheTask from '../../../tasks/updateCache.js'; import UpdateStatsTask from '../../../tasks/updateStats.js'; import { ActivePunishment } from '../../models/ActivePunishment.js'; @@ -52,6 +54,7 @@ import { Global } from '../../models/Global.js'; import { Guild as GuildModel } from '../../models/Guild.js'; import { Level } from '../../models/Level.js'; import { ModLog } from '../../models/ModLog.js'; +import { Reminder } from '../../models/Reminder.js'; import { Stat } from '../../models/Stat.js'; import { StickyRole } from '../../models/StickyRole.js'; import { AllowedMentions } from '../../utils/AllowedMentions.js'; @@ -425,6 +428,7 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re Level.initModel(this.db); StickyRole.initModel(this.db); Stat.initModel(this.db); + Reminder.initModel(this.db); await this.db.sync({ alter: true }); // Sync all tables to fix everything if updated await this.console.success('startup', `Successfully connected to <<database>>.`, false); } catch (e) { diff --git a/src/lib/index.ts b/src/lib/index.ts index 65a6e74..94a7dd9 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -24,6 +24,7 @@ export * from './extensions/discord.js/BushApplicationCommand.js'; export type { BushApplicationCommandManager } from './extensions/discord.js/BushApplicationCommandManager.js'; export type { BushApplicationCommandPermissionsManager } from './extensions/discord.js/BushApplicationCommandPermissionsManager.js'; export type { BushBaseGuildEmojiManager } from './extensions/discord.js/BushBaseGuildEmojiManager.js'; +export type { BushBaseGuildVoiceChannel } from './extensions/discord.js/BushBaseGuildVoiceChannel.js'; export * from './extensions/discord.js/BushButtonInteraction.js'; export * from './extensions/discord.js/BushCategoryChannel.js'; export type { BushChannel } from './extensions/discord.js/BushChannel.js'; @@ -68,6 +69,7 @@ export * from './models/Global.js'; export * from './models/Guild.js'; export * from './models/Level.js'; export * from './models/ModLog.js'; +export * from './models/Reminder.js'; export * from './models/Stat.js'; export * from './models/StickyRole.js'; export * from './utils/AllowedMentions.js'; diff --git a/src/lib/models/Reminder.ts b/src/lib/models/Reminder.ts new file mode 100644 index 0000000..b8cd669 --- /dev/null +++ b/src/lib/models/Reminder.ts @@ -0,0 +1,77 @@ +import { Snowflake } from 'discord.js'; +import { nanoid } from 'nanoid'; +import { type Sequelize } from 'sequelize'; +import { BaseModel } from './BaseModel.js'; +const { DataTypes } = (await import('sequelize')).default; + +export interface ReminderModel { + id: string; + user: Snowflake; + messageUrl: string; + content: string; + created: Date; + expires: Date; + notified: boolean; +} + +export interface ReminderModelCreationAttributes { + id?: string; + user: Snowflake; + messageUrl: string; + content: string; + created: Date; + expires: Date; + notified?: boolean; +} + +export class Reminder extends BaseModel<ReminderModel, ReminderModelCreationAttributes> implements ReminderModel { + /** + * The id of the reminder. + */ + public declare id: string; + + /** + * The user that the reminder is for. + */ + public declare user: Snowflake; + + /** + * The url of the message where the reminder was created. + */ + public declare messageUrl: string; + + /** + * The content of the reminder. + */ + public declare content: string; + + /** + * The date the reminder was created. + */ + public declare created: Date; + + /** + * The date when the reminder expires. + */ + public declare expires: Date; + + /** + * Whether the user has been notified about the reminder. + */ + public declare notified: boolean; + + public static initModel(sequelize: Sequelize): void { + Reminder.init( + { + id: { type: DataTypes.STRING, primaryKey: true, defaultValue: nanoid }, + user: { type: DataTypes.STRING, allowNull: false }, + messageUrl: { type: DataTypes.STRING, allowNull: false }, + content: { type: DataTypes.TEXT, allowNull: false }, + created: { type: DataTypes.DATE, allowNull: false }, + expires: { type: DataTypes.DATE, allowNull: false }, + notified: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false } + }, + { sequelize } + ); + } +} |