Done event channelCreate
This commit is contained in:
@@ -1,6 +1,37 @@
|
||||
const commandH = require('../commandHandler');
|
||||
const bot = require('../botClient').bot;
|
||||
const dbEI = require('../dbEventInterface');
|
||||
const hastebin = require('../hastebin');
|
||||
const configM = require('../configManager');
|
||||
|
||||
exports.loadModule = function loadModule () {
|
||||
|
||||
bot.on('channelCreate', async channel => {
|
||||
if (channel.type !== 0 && channel.type !== 2) return;
|
||||
// Add support for categories
|
||||
// Also, add independent support for each type of channels
|
||||
// Also, parse json with circular object support
|
||||
try {
|
||||
let a = await dbEI.getEvent(channel.guild.id, 'channelCreate');
|
||||
if (a.event.d === true) {
|
||||
let type = "";
|
||||
if (channel.type === 0) {
|
||||
type = "text";
|
||||
}
|
||||
else {
|
||||
type = "voice";
|
||||
}
|
||||
let mention = channel.mention;
|
||||
if (channel.type === 2) mention.shift();
|
||||
let hb = "";
|
||||
if (a.event.msg.includes("$hastebin")) {
|
||||
hb = await hastebin(configM.config.hastebinServer, 'Channel ' + channel.name + ' data as JSON\n\n------------------\n\n' + JSON.stringify(channel));
|
||||
}
|
||||
let finalMessage = a.event.msg.replace('$type', type).replace('$mention', mention).replace('$id', channel.id).replace('$timestamp', channel.createdAt).replace('$hastebin', hb).replace('$name', channel.name);
|
||||
bot.createMessage(a.event.c === 'f' ? a.fallbackChannelId : a.event.c, finalMessage);
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
console.log(e);
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -47,6 +47,7 @@ exports.loadModule = function loadModule () {
|
||||
bot.createMessage(message.channel.id, `Event channel set to <#${channelId}>. The fallback channel for that even has been overriden. To bind again the event to the fallback channel, execute \`event ${match[1]} channel fallback\``);
|
||||
}
|
||||
});
|
||||
// Change the endpoint below, put something that couldn't interfere with the other
|
||||
commandH.endpoint('^event(-set)? (.+) (.+)$', async (match, message) => {
|
||||
let newState = true;
|
||||
if (match[3]) {
|
||||
|
||||
Reference in New Issue
Block a user