Skip to content

Commit

Permalink
[modules/*] Add old event handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
lexisother committed Apr 2, 2023
1 parent 23e4420 commit c144354
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,6 @@ http
.listen(process.env.HEALTH_PORT);

client.login(process.env.DISCORD_BOT_TOKEN);

import './modules/ping';
import './modules/guildMemberAdd';
18 changes: 18 additions & 0 deletions src/modules/guildMemberAdd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { client } from '../index';
import { ChannelType, Events } from 'discord.js';
import { getGeneralChannel } from '../util';

client.on(Events.GuildMemberAdd, async (member) => {
const generalChannel = await getGeneralChannel();

if (generalChannel?.type !== ChannelType.GuildText) {
throw new Error('General channel is not a text channel.');
}

await generalChannel.send(
`Heya~ ${member.displayName}! Welcome to the Fyra Discord, we're the home of products such as tauOS: the next generation, friendly, and private operating system. Our server is also a chill place to talk tech and hangout. If you have any questions, feel free to ask! :3`
);
await generalChannel.send(
`By the way, my name is Raboneko, Fyra's virtual neko assistant, *nya~* It's a pleasure to meet nyu, and I hope you have a great time here as well ^_^`
);
});
23 changes: 23 additions & 0 deletions src/modules/ping.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { client } from '../index';
import { Events } from 'discord.js';

const mentionedResponses = [
'nyes?',
'hewwo~',
'oww, that was loud >_<',
'your friendly robot neko, at your service :3',
'nya?!',
'huh?',
'*runs with toast in mouth*',
'how are nyu?',
'hai!',
'gmeow~'
];

client.on(Events.MessageCreate, async (message) => {
const me = client.user?.id;
if (!me || !message.mentions.has(me)) {
return;
}
await message.reply(mentionedResponses[Math.floor(Math.random() * mentionedResponses.length)]);
});

0 comments on commit c144354

Please sign in to comment.