Skip to content

Commit

Permalink
feat: add praca command (#110)
Browse files Browse the repository at this point in the history
* feat: add praca command

* where testy
  • Loading branch information
AdiPol1359 authored Jun 13, 2023
1 parent 2847c93 commit 9aaac8c
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -70,6 +71,7 @@ const allCommands = [
yesno,
youtube,
stackoverflow,
praca,
];

const cooldowns = new Discord.Collection<string, Discord.Collection<string, number>>();
Expand Down
27 changes: 27 additions & 0 deletions src/commands/praca.spec.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
32 changes: 32 additions & 0 deletions src/commands/praca.ts
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 9aaac8c

Please sign in to comment.