Moved events to files

This commit is contained in:
Jonathan Barrow 2022-05-06 18:23:00 -04:00
parent 5563cb5e10
commit 5e25588511
4 changed files with 92 additions and 70 deletions

View file

@ -12,6 +12,7 @@
},
"extends": "eslint:recommended",
"rules": {
"jsdoc/no-undefined-types": 1,
"require-atomic-updates": "warn",
"no-case-declarations": "off",
"no-empty": "off",
@ -39,5 +40,8 @@
"error",
"always"
]
}
},
"plugins": [
"jsdoc"
]
}

View file

@ -1,5 +1,7 @@
const { SlashCreator, GatewayServer } = require('slash-create');
const Discord = require('discord.js');
const guildMemberAddHandler = require('./events/guildMemberAddHandler');
const messageHandler = require('./events/message');
const config = require('../config.json');
const intents = ['GUILDS', 'GUILD_MEMBERS'];
@ -28,75 +30,8 @@ creator
])
.syncCommands();
bot.on('message', message => {
// Ignore bot messages
if (message.author.bot) return;
// Check if the message is a command and handle it
if (message.content === '.toggleupdates') {
message.reply('Looks like you tried to use a legacy command! Try our new slash commands by just typing "/"!');
return;
}
});
bot.on('guildMemberAdd', member => {
const embed = new Discord.MessageEmbed();
embed.setColor(0x1B1F3B);
embed.setTitle('Pretendo Network');
embed.setURL('https://pretendo.network');
embed.setDescription('\u200b');
embed.setThumbnail('https://i.imgur.com/8clyKqx.png');
embed.setImage('https://i.imgur.com/CF7qgW1.png');
embed.addFields([
{
name: '📃 Social Media',
value: '\u200b'
},
{
name: '<:patreonlogo:886254233786138635> Patreon',
value: 'https://patreon.com/PretendoNetwork'
},
{
name: '<:twitterlogo:886254233962291241> Twitter',
value: 'https://twitter.com/PretendoNetwork'
},
{
name: '<:twitchlogo:886254234201362473> Twitch',
value: 'https://twitch.tv/PretendoNetwork'
},
{
name: '<:youtubelogo:886254234226528337> YouTube',
value: 'https://youtube.com/c/PretendoNetwork'
},
{
name: '\u200b',
value: '\u200b'
},
{
name: '<:rulestext:886254514141806643> Rules',
value: '\u200b'
},
{
name: ':one:',
value: 'No advertising unless explicitly allowed to do so by one of the developers'
},
{
name: ':two:',
value: 'Do not share anything illegal. This includes illegal game/fw dumps, any console SDK, etc. We are unsure as to what is illegal to share, so keep all that to the DMs just to be safe'
},
{
name: ':three:',
value: 'Respect channel names and topics. Offtopic chat goes in the offtopic channel'
},
{
name: ':four:',
value: 'Be kind. If someone asks a question you can help with, be nice about helping them. Know your audience'
}
]);
member.send('Thank you for joining the Pretendo Network Discord server! Check below for some server information and links', { embed });
});
bot.on('guildMemberAdd', guildMemberAddHandler);
bot.on('message', messageHandler);
bot.login(config.token).then(() => {
console.log('ready');

View file

@ -0,0 +1,66 @@
const Discord = require('discord.js');
/**
*
* @param {Discord.GuildMember} member
*/
function guildMemberAddHandler(member) {
const embed = new Discord.MessageEmbed();
embed.setColor(0x1B1F3B);
embed.setTitle('Pretendo Network');
embed.setURL('https://pretendo.network');
embed.setDescription('\u200b');
embed.setThumbnail('https://i.imgur.com/8clyKqx.png');
embed.setImage('https://i.imgur.com/CF7qgW1.png');
embed.addFields([
{
name: '📃 Social Media',
value: '\u200b'
},
{
name: '<:patreonlogo:886254233786138635> Patreon',
value: 'https://patreon.com/PretendoNetwork'
},
{
name: '<:twitterlogo:886254233962291241> Twitter',
value: 'https://twitter.com/PretendoNetwork'
},
{
name: '<:twitchlogo:886254234201362473> Twitch',
value: 'https://twitch.tv/PretendoNetwork'
},
{
name: '<:youtubelogo:886254234226528337> YouTube',
value: 'https://youtube.com/c/PretendoNetwork'
},
{
name: '\u200b',
value: '\u200b'
},
{
name: '<:rulestext:886254514141806643> Rules',
value: '\u200b'
},
{
name: ':one:',
value: 'No advertising unless explicitly allowed to do so by one of the developers'
},
{
name: ':two:',
value: 'Do not share anything illegal. This includes illegal game/fw dumps, any console SDK, etc. We are unsure as to what is illegal to share, so keep all that to the DMs just to be safe'
},
{
name: ':three:',
value: 'Respect channel names and topics. Offtopic chat goes in the offtopic channel'
},
{
name: ':four:',
value: 'Be kind. If someone asks a question you can help with, be nice about helping them. Know your audience'
}
]);
member.send('Thank you for joining the Pretendo Network Discord server! Check below for some server information and links', { embed });
}
module.exports = guildMemberAddHandler;

17
src/events/message.js Normal file
View file

@ -0,0 +1,17 @@
const Discord = require('discord.js');
/**
*
* @param {Discord.Message} message
*/
function messageHandler(message) {
if (message.author.bot) return;
// Check if the message is a command and handle it
if (message.content === '.toggleupdates') {
message.reply('Looks like you tried to use a legacy command! Try our new slash commands by just typing "/"!');
return;
}
}
module.exports = messageHandler;