added events

This commit is contained in:
Benjamin Kyd
2020-07-14 00:28:33 +01:00
parent c7a4ec9e4b
commit ed24fac246
3 changed files with 72 additions and 7 deletions

View File

@@ -1,11 +1,12 @@
const Logger = require('./logger.js');
const Database = require('./database.js');
const Events = require('./discordevents.js');
const Commands = require('./discordcommands.js');
const fs = require('fs');
const Eris = require('eris');
let bot;
module.exports.bot;
module.exports.setup = async function()
{
@@ -13,10 +14,10 @@ module.exports.setup = async function()
if (!process.env.BOT_TOKEN) Logger.panic('No BOT_TOKEN in .env file!')
bot = new Eris(process.env.BOT_TOKEN, {allowedMentions: false, restMode: true});
this.bot = new Eris(process.env.BOT_TOKEN, {allowedMentions: false, restMode: true});
bot.on('ready', async () => {
Logger.info(`Discord logged in as ${bot.user.username}#${bot.user.discriminator}`);
this.bot.on('ready', async () => {
Logger.info(`Discord logged in as ${this.bot.user.username}#${this.bot.user.discriminator}`);
let typestr = process.env.BOT_GAME_TYPE || 'playing';
let game = process.env.BOT_GAME || '*';
@@ -29,12 +30,14 @@ module.exports.setup = async function()
default: type = 3; break;
}
bot.editStatus('online', {name: game, type: type});
this.bot.editStatus('online', {name: game, type: type});
});
// settup events
Events.setup();
Commands.registerCommands();
bot.connect();
this.bot.connect();
}

View File

@@ -0,0 +1,13 @@
const Logger = require('./logger.js');
let Commands = {};
module.exports.registerCommands = async function()
{
Logger.info('Registering commands');
}
module.exports.newMessage = async function(message)
{
console.log(message.content);
}

View File

@@ -0,0 +1,49 @@
const Logger = require('./logger.js');
const Discord = require('./discord.js');
const Commands = require('./discordcommands.js');
module.exports.setup = async function()
{
Logger.info('Setting up discord listeners');
Discord.bot.on('channelCreate', async (channel) => {});
Discord.bot.on('channelDelete', async (channel) => {});
Discord.bot.on('channelPinUpdate', async (channel, timestamp, oldtimestamp) => {});
Discord.bot.on('channelUpdate', async (channel, oldchannel) => {});
Discord.bot.on('guildBanAdd', async (guild, user) => {});
Discord.bot.on('guildBanRemove', async (guild, user) => {});
Discord.bot.on('guildCreate', async (guild) => {});
Discord.bot.on('guildDelete', async (guild) => {});
Discord.bot.on('guildEmojisUpdate', async (guild, emojis, oldemojis) => {});
Discord.bot.on('guildMemberAdd', async (guild, member) => {});
Discord.bot.on('guildMemberRemove', async (guild, member) => {});
Discord.bot.on('guildMemberUpdate', async (guild, member, oldmember) => {});
Discord.bot.on('guildRoleCreate', async (guild, role) => {});
Discord.bot.on('guildRoleDelete', async (guild, role) => {});
Discord.bot.on('guildRoleUpdate', async (guild, role, oldrole) => {});
Discord.bot.on('guildUpdate', async (guild, oldguild) => {});
Discord.bot.on('inviteCreate', async (guild, invite) => {});
Discord.bot.on('inviteDelete', async (guild, invite) => {});
Discord.bot.on('messageCreate', async (message) => Commands.newMessage(message));
Discord.bot.on('messageDelete', async (message) => {});
Discord.bot.on('messageDeleteBulk', async (messages) => {});
Discord.bot.on('messageReactionAdd', async (message, emoji) => {});
Discord.bot.on('messageReactionRemove', async (message, emoji) => {});
Discord.bot.on('messageReactionRemoveAll', async (message) => {});
Discord.bot.on('messageReactionRemoveEmoji', async (message, emoji) => {});
Discord.bot.on('messageUpdate', async (message, oldmessage) => {});
Discord.bot.on('presenceUpdate', async (member, oldprescence) => {});
Discord.bot.on('userUpdate', async (user, olduser) => {});
Discord.bot.on('voiceChannelJoin', async (member, newchannel) => {});
Discord.bot.on('voiceChannelLeave', async (member, oldchannel) => {});
Discord.bot.on('voiceChannelSwitch', async (member, newchannel, oldchannel) => {});
Discord.bot.on('voiceStateUpdate', async (member, oldstate) => {});
Discord.bot.on('webhooksUpdate', async (data, channelid, guildid) => {});
Discord.bot.on('warn', async (message, id) => {});
Discord.bot.on('error', async (error, id) => {});
Discord.bot.on('disconnect', async (options) => {});
}
// Handlers