diff --git a/src/class/Client.ts b/src/class/Client.ts index 8a8eabb..28470cc 100644 --- a/src/class/Client.ts +++ b/src/class/Client.ts @@ -3,9 +3,10 @@ import mongoose from 'mongoose'; import { promises as fs } from 'fs'; import { Collection, Command, LocalStorage, Util, ServerManagement, Event } from '.'; import { File, FileInterface, Member, MemberInterface, Moderation, ModerationInterface, PagerNumber, PagerNumberInterface, Rank, RankInterface, Redirect, RedirectInterface } from '../models'; +import { Config } from '../../types'; // eslint-disable-line export default class Client extends eris.Client { - public config: { token: string, prefix: string, guildID: string, mongoDB: string, emailPass: string, }; + public config: Config; public commands: Collection; diff --git a/src/class/Util.ts b/src/class/Util.ts index 184e55d..7df6ae9 100644 --- a/src/class/Util.ts +++ b/src/class/Util.ts @@ -1,7 +1,7 @@ /* eslint-disable no-bitwise */ import nodemailer from 'nodemailer'; import signale from 'signale'; -import { Member, Message, Guild, PrivateChannel, GroupChannel, Role, AnyGuildChannel } from 'eris'; +import { Member, Message, Guild, PrivateChannel, GroupChannel, Role, AnyGuildChannel, WebhookPayload } from 'eris'; import { Client, Command, Moderation, RichEmbed } from '.'; import { statusMessages as emotes } from '../configs/emotes.json'; @@ -79,7 +79,7 @@ export default class Util { public async handleError(error: Error, message?: Message, command?: Command, disable = true): Promise { try { this.signale.error(error); - const info = { content: `\`\`\`js\n${error.stack || error}\n\`\`\``, embed: null }; + const info: WebhookPayload = { content: `\`\`\`js\n${error.stack || error}\n\`\`\``, embeds: [] }; if (message) { const embed = new RichEmbed(); embed.setColor('FF0000'); @@ -93,9 +93,9 @@ export default class Util { else guild = message.channel.guild.id; embed.addField('Message link', `[Click here](https://discordapp.com/channels/${guild}/${message.channel.id}/${message.id})`, true); embed.setTimestamp(new Date(message.timestamp)); - info.embed = embed; + info.embeds.push(embed); } - await this.client.createMessage('595788220764127272', info); + await this.client.executeWebhook(this.client.config.webhookID, this.client.config.webhookToken, info); const msg = message ? message.content.slice(this.client.config.prefix.length).trim().split(/ +/g) : []; if (command && disable) this.resolveCommand(msg).then((c) => { c.cmd.enabled = false; }); if (message) message.channel.createMessage(`***${this.emojis.ERROR} An unexpected error has occured - please contact a Staff member.${command && disable ? ' This command has been disabled.' : ''}***`); diff --git a/src/configs/acknowledgements.json b/src/configs/acknowledgements.json index 58db6c6..1ea629e 100644 --- a/src/configs/acknowledgements.json +++ b/src/configs/acknowledgements.json @@ -124,6 +124,13 @@ "emailAddress": "nicolas@staff.libraryofcode.org", "bio": "I write C++ to pay off my student loans" }, + { + "name": "Sterben", + "id": "241361691730903040", + "dept": "Associate", + "emailAddress": "sterben@staff.libraryofcode.org", + "bio": "im bored" + }, { "name": "Null", "id": "323673862971588609", diff --git a/src/main.ts b/src/main.ts index 4677d4b..d1f0ef7 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,10 +6,11 @@ import { promises as fs } from 'fs'; import { Client } from './class'; import * as eventFiles from './events'; import * as commandFiles from './commands'; +import { Config } from '../types'; // eslint-disable-line async function main(): Promise { const read = await fs.readFile('../config.yaml', 'utf8'); - const config: { token: string, prefix: string, guildID: string, mongoDB: string, emailPass: string } = parse(read); + const config: Config = parse(read); const client = new Client(config.token, { defaultImageFormat: 'png', restMode: true }); client.config = config; await client.loadDatabase(); diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000..971ffc9 --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,9 @@ +export declare interface Config { + token: string; + prefix: string; + guildID: string; + mongoDB: string; + emailPass: string; + webhookID: string; + webhookToken: string; +}