mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 22:21: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:
parent
21fdd76863
commit
fd47ba9d69
3 changed files with 12 additions and 11 deletions
|
@ -4,7 +4,7 @@ import yaml from "js-yaml";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
const fsp = fs.promises;
|
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 { SimpleError } from "./SimpleError";
|
||||||
|
|
||||||
import DiscordRESTError from "eris/lib/errors/DiscordRESTError"; // tslint:disable-line
|
import DiscordRESTError from "eris/lib/errors/DiscordRESTError"; // tslint:disable-line
|
||||||
|
@ -162,13 +162,15 @@ connect().then(async conn => {
|
||||||
customArgumentTypes,
|
customArgumentTypes,
|
||||||
|
|
||||||
sendSuccessMessageFn(channel, body) {
|
sendSuccessMessageFn(channel, body) {
|
||||||
const guildId = channel instanceof TextChannel ? channel.guild.id : null;
|
const guildId = channel instanceof TextChannel ? channel.guild.id : undefined;
|
||||||
const emoji = (guildId ? bot.getGuildData(guildId).config.success_emoji : null) ?? "default emoji here";
|
const emoji = guildId ? bot.getGuildData(guildId).config.success_emoji : undefined;
|
||||||
channel.createMessage(successMessage(body, emoji));
|
channel.createMessage(successMessage(body, emoji));
|
||||||
},
|
},
|
||||||
|
|
||||||
sendErrorMessageFn(channel, body) {
|
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));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import { IGlobalConfig, IGuildConfig, Knub } from "knub";
|
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 {
|
export interface IZeppelinGuildConfig extends IGuildConfig {
|
||||||
// To fill
|
success_emoji?: string;
|
||||||
|
error_emoji?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IZeppelinGlobalConfig extends IGlobalConfig {
|
export interface IZeppelinGlobalConfig extends IGlobalConfig {
|
||||||
|
|
|
@ -264,12 +264,12 @@ export function convertMSToDelayString(ms: number): string {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function successMessage(str, emoji) {
|
export function successMessage(str, emoji = "<:zep_check:650361014180904971>") {
|
||||||
return `${emoji} ${str}`;
|
return emoji ? `${emoji} ${str}` : str;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function errorMessage(str) {
|
export function errorMessage(str, emoji = "⚠") {
|
||||||
return `⚠ ${str}`;
|
return emoji ? `${emoji} ${str}` : str;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function get(obj, path, def?): any {
|
export function get(obj, path, def?): any {
|
||||||
|
|
Loading…
Add table
Reference in a new issue