Set default success emoji to zep_check; add error_emoji support, mirroring success_emoji but for error messages

This commit is contained in:
Dragory 2020-01-12 13:44:31 +02:00
parent 21fdd76863
commit fd47ba9d69
3 changed files with 12 additions and 11 deletions

View file

@ -4,7 +4,7 @@ import yaml from "js-yaml";
import fs from "fs";
const fsp = fs.promises;
import { Knub, logger, PluginError, Plugin, IGlobalConfig, IGuildConfig, IGuildData } from "knub";
import { Knub, logger, PluginError, Plugin, IGlobalConfig, IGuildConfig } from "knub";
import { SimpleError } from "./SimpleError";
import DiscordRESTError from "eris/lib/errors/DiscordRESTError"; // tslint:disable-line
@ -162,13 +162,15 @@ connect().then(async conn => {
customArgumentTypes,
sendSuccessMessageFn(channel, body) {
const guildId = channel instanceof TextChannel ? channel.guild.id : null;
const emoji = (guildId ? bot.getGuildData(guildId).config.success_emoji : null) ?? "default emoji here";
const guildId = channel instanceof TextChannel ? channel.guild.id : undefined;
const emoji = guildId ? bot.getGuildData(guildId).config.success_emoji : undefined;
channel.createMessage(successMessage(body, emoji));
},
sendErrorMessageFn(channel, body) {
channel.createMessage(errorMessage(body));
const guildId = channel instanceof TextChannel ? channel.guild.id : undefined;
const emoji = guildId ? bot.getGuildData(guildId).config.error_emoji : undefined;
channel.createMessage(errorMessage(body, emoji));
},
},
});