diff --git a/src/commands/index.ts b/src/commands/index.ts index fca23f3..c031b1e 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -18,6 +18,7 @@ import mongodb from './mongodb'; import mydevil from './mydevil'; import npm from './npm'; import odpowiedz from './odpowiedz'; +import praca from './praca'; import prs from './prs'; import prune from './prune'; import quiz from './quiz'; @@ -70,6 +71,7 @@ const allCommands = [ yesno, youtube, stackoverflow, + praca, ]; const cooldowns = new Discord.Collection>(); diff --git a/src/commands/praca.spec.ts b/src/commands/praca.spec.ts new file mode 100644 index 0000000..15bf180 --- /dev/null +++ b/src/commands/praca.spec.ts @@ -0,0 +1,27 @@ +import { expect } from 'chai'; +import type Discord from 'discord.js'; + +import { getMessageMock } from '../../test/mocks'; + +import praca from './praca'; + +describe('praca', () => { + it('should send links to websites', async () => { + const mockLinks = [ + 'https://justjoin.it/', + 'https://nofluffjobs.com/', + 'https://bulldogjob.pl/', + 'https://www.pracuj.pl/', + ]; + const msg = getMessageMock('msg', {}); + + await praca.execute(msg as unknown as Discord.Message, []); + + const embedData = ( + msg.channel.send.args[0][0] as { readonly embeds: readonly Discord.EmbedBuilder[] } + ).embeds[0].data; + + expect(embedData.title).to.equal('Najlepsze portale z ofertami pracy'); + expect(mockLinks.every((link) => embedData.description?.includes(link))).to.equal(true); + }); +}); diff --git a/src/commands/praca.ts b/src/commands/praca.ts new file mode 100644 index 0000000..e5fa3a5 --- /dev/null +++ b/src/commands/praca.ts @@ -0,0 +1,32 @@ +import { EmbedBuilder } from 'discord.js'; + +import type { Command } from '../types'; + +const links = [ + 'https://justjoin.it/', + 'https://nofluffjobs.com/', + 'https://bulldogjob.pl/', + 'https://www.pracuj.pl/', +]; + +const praca: Command = { + name: 'praca', + args: 'prohibited', + description: 'Lista najlepszych portali z ofertami pracy', + execute(msg) { + const embed = new EmbedBuilder() + .setTitle('Najlepsze portale z ofertami pracy') + .setDescription(links.map((link, i) => `${i + 1}. ${link}`).join('\n')) + .setColor('#5ab783') + .setFooter({ + text: 'Type of Web, Discord, Polska', + iconURL: + 'https://cdn.discordapp.com/avatars/574682557988470825/8071299007c2d575c0912255baa19509.png?size=64', + }) + .setTimestamp(); + + return msg.channel.send({ embeds: [embed] }); + }, +}; + +export default praca;