3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

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));
},
},
});

View file

@ -1,9 +1,8 @@
import { IGlobalConfig, IGuildConfig, Knub } from "knub";
// Remove this tslint exception once there are properties in the interface
// tslint:disable-next-line
export interface IZeppelinGuildConfig extends IGuildConfig {
// To fill
success_emoji?: string;
error_emoji?: string;
}
export interface IZeppelinGlobalConfig extends IGlobalConfig {

View file

@ -264,12 +264,12 @@ export function convertMSToDelayString(ms: number): string {
return result;
}
export function successMessage(str, emoji) {
return `${emoji} ${str}`;
export function successMessage(str, emoji = "<:zep_check:650361014180904971>") {
return emoji ? `${emoji} ${str}` : str;
}
export function errorMessage(str) {
return ` ${str}`;
export function errorMessage(str, emoji = "⚠") {
return emoji ? `${emoji} ${str}` : str;
}
export function get(obj, path, def?): any {