feat(notif): add settings for Discord bot username & avatar URL (#1113)

This commit is contained in:
TheCatLady
2021-03-09 07:42:32 -05:00
committed by GitHub
parent e5f5bdb95c
commit 3384eb1c47
5 changed files with 73 additions and 9 deletions

View File

@@ -71,7 +71,7 @@ interface DiscordRichEmbed {
interface DiscordWebhookPayload {
embeds: DiscordRichEmbed[];
username: string;
username?: string;
avatar_url?: string;
tts: boolean;
content?: string;
@@ -203,8 +203,11 @@ class DiscordAgent
): Promise<boolean> {
logger.debug('Sending discord notification', { label: 'Notifications' });
try {
const settings = getSettings();
const webhookUrl = this.getSettings().options.webhookUrl;
const {
botUsername,
botAvatarUrl,
webhookUrl,
} = this.getSettings().options;
if (!webhookUrl) {
return false;
@@ -222,7 +225,8 @@ class DiscordAgent
}
await axios.post(webhookUrl, {
username: settings.main.applicationTitle,
username: botUsername,
avatar_url: botAvatarUrl,
embeds: [this.buildEmbed(type, payload)],
content,
allowed_mentions: {