From c1443547b8ed54b66bf020ea646dd956657d7d3b Mon Sep 17 00:00:00 2001 From: Alyxia Date: Sun, 2 Apr 2023 17:15:56 +0200 Subject: [PATCH] [modules/*] Add old event handlers --- src/index.ts | 3 +++ src/modules/guildMemberAdd.ts | 18 ++++++++++++++++++ src/modules/ping.ts | 23 +++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 src/modules/guildMemberAdd.ts create mode 100644 src/modules/ping.ts diff --git a/src/index.ts b/src/index.ts index 5a73edd..e7920a8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -67,3 +67,6 @@ http .listen(process.env.HEALTH_PORT); client.login(process.env.DISCORD_BOT_TOKEN); + +import './modules/ping'; +import './modules/guildMemberAdd'; diff --git a/src/modules/guildMemberAdd.ts b/src/modules/guildMemberAdd.ts new file mode 100644 index 0000000..a50f0a1 --- /dev/null +++ b/src/modules/guildMemberAdd.ts @@ -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 ^_^` + ); +}); diff --git a/src/modules/ping.ts b/src/modules/ping.ts new file mode 100644 index 0000000..befb8f0 --- /dev/null +++ b/src/modules/ping.ts @@ -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)]); +});