diff --git a/src/discord/services/discord.service.spec.ts b/src/discord/services/discord.service.spec.ts index 811cdafed..4efd27af1 100644 --- a/src/discord/services/discord.service.spec.ts +++ b/src/discord/services/discord.service.spec.ts @@ -38,6 +38,16 @@ describe('DiscordService', () => { client.emit('ready'); expect(spy).toHaveBeenCalledWith('FAKE_DISCORD_BOT_TOKEN'); }); + + it('should send notification', done => { + const spy = jest.spyOn(adminChannel, 'send'); + service.onModuleInit(); + client.emit('ready'); + setTimeout(() => { + expect(spy).toHaveBeenCalled(); + done(); + }, 0); + }); }); describe('when logged in', () => { diff --git a/src/discord/services/discord.service.ts b/src/discord/services/discord.service.ts index b9d73ddd5..b0e196a15 100644 --- a/src/discord/services/discord.service.ts +++ b/src/discord/services/discord.service.ts @@ -1,6 +1,7 @@ import { Injectable, Logger, OnModuleInit } from '@nestjs/common'; import { Client, Guild, TextChannel, Role } from 'discord.js'; import { Environment } from '@/environment/environment'; +import { version } from '../../../package.json'; @Injectable() export class DiscordService implements OnModuleInit { @@ -21,6 +22,7 @@ export class DiscordService implements OnModuleInit { }); this.client.login(this.environment.discordBotToken) + .then(() => this.getAdminsChannel().send(`Server version ${version} started.`)) .catch(error => this.logger.error(error.toString())); } }