diff --git a/models/anime.js b/models/anime.js new file mode 100644 index 0000000..6af1ed6 --- /dev/null +++ b/models/anime.js @@ -0,0 +1,20 @@ +const mongoose = require('mongoose'); + +const AniSchema = new mongoose.Schema({ + id: {type: String, unique: true}, + name: String, + plot: String, + publishers: [String], + studio: [String], + airStartDate: Date, + airEndDate: Date, + isComplete: Boolean, + seasons: Number, + episodes: Number, + genres: [String], + tags: [String], + characters: [String], + streamAt: [String] +}); + +module.exports = mongoose.model('anime', AniSchema); \ No newline at end of file diff --git a/models/user.js b/models/user.js index fb9122c..29e5e29 100644 --- a/models/user.js +++ b/models/user.js @@ -8,6 +8,8 @@ const UserSchema = new mongoose.Schema({ statusclearmode: {type: String, default: 'auto'}, statusclearat: {type: Date, default: null}, statussetat: {type: Date, default: null}, + statusshowcleartime: {type: Boolean, default: true}, + statusshowsettime: {type: Boolean, default: true}, support: {type: Boolean, default: false}, staff: {type: Boolean, default: false}, admin: {type: Boolean, default: false}, diff --git a/util/ts/pagination.ts b/util/ts/pagination.ts new file mode 100644 index 0000000..3f3ce96 --- /dev/null +++ b/util/ts/pagination.ts @@ -0,0 +1,112 @@ +import {MessageEmbed, Message, Client} from 'discord.js'; + +import wait = require('../../util/wait'); + +export class Pagination { + title: string; + pages: Page[]; + zeroPage: Page | MessageEmbed; + pageTemplate: MessageEmbed; + message: Message; + timeout: Number; + description: string; + activationMessage: Message; + client: Client; + currentpos: number = 0; + + + + constructor (title: string, pages: Page[], zeroPage: Page | MessageEmbed, client: Client, message: Message, activationMessage: Message, timeout: number, description?: string, pageTemplate?: MessageEmbed) { + this.title = title; + this.pages = pages; + this.zeroPage = zeroPage; + this.message = message; + this.timeout = timeout; + this.activationMessage = activationMessage; + this.client = client; + + this.description = description ? description : `Requested by ${activationMessage.guild ? activationMessage.member.displayName : activationMessage.author.username}.`; + + this.pageTemplate = pageTemplate + ? pageTemplate + : new MessageEmbed() + .setDescription(this.description) + .addField('Navigation', `Click or tap the arrows below this message to navigate through the pages!\n\n*This menu will timeout in ${this.timeout}ms.`) + .setColor('c375f0') + .setFooter('Natsuki', this.client.user.avatarURL()) + .setTimestamp(); + }; + + + + public addPage(page: Page): Pagination { + this.pages.push(page); + return this; + }; + + public render(pos: number): Pagination { + let page = this.pages[this.currentpos]; + let pageEmbed: MessageEmbed = new MessageEmbed() + .setTitle(`${this.title} -> ${page.title}`) + .setDescription(`${this.pageTemplate.description ? this.pageTemplate.description : this.description}\n\n${page.description}`) + .setColor(this.pageTemplate.hexColor ? this.pageTemplate.hexColor : 'c375f0') + .setFooter(this.pageTemplate.footer ? `${this.pageTemplate.footer.text} | Page ${this.currentpos + 1} of ${this.pages.length}` : `Natsuki | Page ${this.currentpos + 1} of ${this.pages.length}`) + .setTimestamp(); + let item: PageItem; for (item of page.items) {pageEmbed.addField(item.title, item.text);} + if (this.pageTemplate.thumbnail) {pageEmbed.setThumbnail(this.pageTemplate.thumbnail.url);} + + this.message.edit(pageEmbed); + + return this; + }; + + public nextPage(): Pagination { + return this.render(this.currentpos < (this.pages.length - 1) ? this.currentpos + 1 : this.currentpos); + }; + + public prevPage(): Pagination { + return this.render(this.currentpos > 0 ? this.currentpos - 1 : this.currentpos); + }; + + public destroy(delmsg?: boolean, fmsg?: Message): Pagination { + return this; + }; + + public resetTimeout(newTimeout?: number): Pagination { + return this; + }; + + public init(): Pagination { + return this; + }; + +} + + + +export class Page { + items: PageItem[] = []; + title: string; + description: string; + + + + constructor(title: string, items: PageItem[], description?: string) { + this.title = title; + this.items = items; + this.description = description; + }; + + + + public addItem(item: PageItem): Page { + this.items.push(item); + return this; + }; + +} + +interface PageItem { + title: string, + text: string +} \ No newline at end of file