Merge branch 'dev' of gitlab.libraryofcode.org:engineering/communityrelations into dev
commit
b255b7fd05
|
@ -3,9 +3,10 @@ import mongoose from 'mongoose';
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import { Collection, Command, LocalStorage, Util, ServerManagement, Event } from '.';
|
import { Collection, Command, LocalStorage, Util, ServerManagement, Event } from '.';
|
||||||
import { File, FileInterface, Member, MemberInterface, Moderation, ModerationInterface, PagerNumber, PagerNumberInterface, Rank, RankInterface, Redirect, RedirectInterface } from '../models';
|
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 {
|
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<Command>;
|
public commands: Collection<Command>;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* eslint-disable no-bitwise */
|
/* eslint-disable no-bitwise */
|
||||||
import nodemailer from 'nodemailer';
|
import nodemailer from 'nodemailer';
|
||||||
import signale from 'signale';
|
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 { Client, Command, Moderation, RichEmbed } from '.';
|
||||||
import { statusMessages as emotes } from '../configs/emotes.json';
|
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<void> {
|
public async handleError(error: Error, message?: Message, command?: Command, disable = true): Promise<void> {
|
||||||
try {
|
try {
|
||||||
this.signale.error(error);
|
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) {
|
if (message) {
|
||||||
const embed = new RichEmbed();
|
const embed = new RichEmbed();
|
||||||
embed.setColor('FF0000');
|
embed.setColor('FF0000');
|
||||||
|
@ -93,9 +93,9 @@ export default class Util {
|
||||||
else guild = message.channel.guild.id;
|
else guild = message.channel.guild.id;
|
||||||
embed.addField('Message link', `[Click here](https://discordapp.com/channels/${guild}/${message.channel.id}/${message.id})`, true);
|
embed.addField('Message link', `[Click here](https://discordapp.com/channels/${guild}/${message.channel.id}/${message.id})`, true);
|
||||||
embed.setTimestamp(new Date(message.timestamp));
|
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) : [];
|
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 (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.' : ''}***`);
|
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.' : ''}***`);
|
||||||
|
|
|
@ -6,10 +6,11 @@ import { promises as fs } from 'fs';
|
||||||
import { Client } from './class';
|
import { Client } from './class';
|
||||||
import * as eventFiles from './events';
|
import * as eventFiles from './events';
|
||||||
import * as commandFiles from './commands';
|
import * as commandFiles from './commands';
|
||||||
|
import { Config } from '../types'; // eslint-disable-line
|
||||||
|
|
||||||
async function main(): Promise<void> {
|
async function main(): Promise<void> {
|
||||||
const read = await fs.readFile('../config.yaml', 'utf8');
|
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 });
|
const client = new Client(config.token, { defaultImageFormat: 'png', restMode: true });
|
||||||
client.config = config;
|
client.config = config;
|
||||||
await client.loadDatabase();
|
await client.loadDatabase();
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
export declare interface Config {
|
||||||
|
token: string;
|
||||||
|
prefix: string;
|
||||||
|
guildID: string;
|
||||||
|
mongoDB: string;
|
||||||
|
emailPass: string;
|
||||||
|
webhookID: string;
|
||||||
|
webhookToken: string;
|
||||||
|
}
|
Loading…
Reference in New Issue