-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
66 lines (55 loc) · 3.5 KB
/
index.js
File metadata and controls
66 lines (55 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//=======================================================================================================
//Imports the necessary user code files to the index in order for later use
//=======================================================================================================
const Discord = require('discord.js')// imports the discord js library
const client = new Discord.Client();
const { token } = require('./config.json');
//Put developerID in ids.json in devid when working on channelcreator to override locked commands
//Include Command and Server handler code
const command = require('./user_code/command')
//Include rest of exported commands
const Server = require("./user_code/Server");
const AutoCodeBlock = require("./user_code/AutoCodeBlock");
/* =======================================================================================================
The Client.once belowRuns one time when the bot first starts up... We use it to confirm that the bot
does not crash on startup.
=======================================================================================================*/
client.once('ready', () =>
{
console.info(`Logged in as ${client.user.tag}!`);
console.info("Ready and stable!"); //Displays Ready and stable in console on run to verify the bot actually starts and doesnt crash
client.user.setActivity("watching out for activity/accomplishments!"); //Sets the discord status activity of the bot to a specific string
});
/*=======================================================================================================
The cronjob code below Completes a cronjob task at 9 AM everyday
//=======================================================================================================*/
//Server.cronjobs(client)
//This cronjob has been disabled as of 5.5.2022 as it is no longer needed to check up on people's daily progress for COSC 481W
/*=======================================================================================================
The client.on section below activates when anybody on the server sends a message on any server the bot is apart of.
//=======================================================================================================*/
client.on("message", message =>
{
//Ignores bots from deleting their own messages
if(message.author.bot)
return;
//Code block to automatically format code blocks based on detected code-words
AutoCodeBlock.autoCodeBlock(message);
//Basic ping command to check the status and delay time of the bot
command(message, /*Message going into command function */
'ping', /*Command headed into command function */
RETURN /*Return from command method, should NOT be used in most situations */=> {
message.channel.send(`🏓 Latency is ${Date.now() - message.createdTimestamp}ms. API Latency is ${Math.round(client.ws.ping)}ms`);
})
command(message, /*Message going into command function */
'verify', /*Command headed into command function */
RETURN /*Return from command method, should NOT be used in most situations */=> {
client.channels.cache.get(`946151295830614076`).send(`<@&930947146834935938> What have you accomplished today for the current Sprint?`);
})
//Halts bot with response (Activated by Brendan only!)
command(message, 'kill', RETURN => {
Server.kill(message);
})
}); //End of message sent loop
//Logs the bot into the token value given on the config
client.login(token)