woomy/src/events/ready.js

61 lines
1.8 KiB
JavaScript
Raw Normal View History

2020-01-25 10:02:43 +00:00
const moment = require("moment");
module.exports = client => {
const timestamp = `${moment().format("YYYY-MM-DD HH:mm:ss")}`;
const activityArray = client.commands.keyArray();
client.lockActivity = false;
2020-03-26 07:26:22 +00:00
let guild, channel, channel1;
if(client.config.loggingServer.length > 0) {
try {
guild = client.guilds.cache.get(client.config.loggingServer)
} catch(err) {
client.logger.error("Could not find loggingServer server (is the ID valid?):\n" + err);
process.exit(1);
};
if(client.config.consoleLogs.length > 0) {
try {
2020-03-26 07:47:48 +00:00
channel1 = guild.channels.cache.get(client.config.consoleLogs)
2020-03-26 07:26:22 +00:00
} catch(err) {
client.logger.error("Could not find consoleLogs channel (is the ID valid?):\n" + err);
process.exit(1);
};
};
if(client.config.startupLogs.length > 0) {
try {
channel = guild.channels.cache.get(client.config.startupLogs)
} catch(err) {
client.logger.error("Could not find startupLogs channel (is the ID valid?):\n" + err);
process.exit(1);
};
};
};
2020-01-25 10:02:43 +00:00
2020-03-26 07:48:03 +00:00
if(client.devmode == true) {
2020-01-25 10:02:43 +00:00
client.logger.warn("Running in development mode.")
prefix = client.config.defaultSettings.devprefix;
} else {
prefix = client.config.defaultSettings.prefix;
2020-03-26 07:47:48 +00:00
if(channel) {
channel.send(`Bot started at \`${timestamp}\``);
2020-03-26 07:26:22 +00:00
};
2020-03-26 04:31:32 +00:00
};
2020-01-25 10:02:43 +00:00
let randomActivity = activityArray.random();
2020-03-09 01:11:33 +00:00
client.user.setActivity(`${prefix + randomActivity} | v${client.version.number}`, {type: "PLAYING"});
2020-03-26 04:31:32 +00:00
2020-01-25 10:02:43 +00:00
setInterval(() => {
randomActivity = activityArray.random();
2020-03-26 04:31:32 +00:00
if(client.lockActivity == false) {
client.user.setActivity(`${prefix + randomActivity} | v${client.version.number}`, {type: "PLAYING"});
};
2020-03-09 01:11:33 +00:00
}, 30000);
2020-03-26 07:26:22 +00:00
client.logger.log(`Connected to Discord as ${client.user.tag} | v${client.version.number}`, 'ready');
2020-01-25 10:02:43 +00:00
};