Minor cleanup

This commit is contained in:
Izwzyzx 2024-10-27 11:23:12 -05:00
parent 1ec9c93bda
commit 7162eb7d93
3 changed files with 25 additions and 21 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
# ignore all files in export dir
export/
modules/
releases/
# ignore bot settings file
settings.json

View File

@ -79,8 +79,8 @@ class Onequestionmark {
/**
* The `onReady()` function is run upon a successful `Bot.connect()`
*/
* The `onReady()` function is run upon a successful `Bot.connect()`
*/
public static function onReady() {
Sys.sleep(1);
Sys.println('[${timestamp()}] Bot is online');
@ -98,8 +98,9 @@ class Onequestionmark {
/**
* The `onMessageCreate()` event provides the bulk of onequestionmark's functionality. This is what triggers when a new Discord message is received, and contains the bot's command processor.
*/
* The `onMessageCreate()` event provides the bulk of onequestionmark's functionality.
* This is what triggers when a new Discord message is received, and contains the bot's command processor.
*/
public static function onMessageCreate(m:Message) {
// DevMode check
if ((!settings.devmode) || (m.guild_id == settings.devserver)) {
@ -345,8 +346,9 @@ class Onequestionmark {
/**
* This function starts the "Meme of the Day" system. A temporary timer is set that counts down to the next MOTD event, at which point the main timer is started on a 24 hour loop.
*/
* This function starts the "Meme of the Day" system.
* A temporary timer is set that counts down to the next MOTD event, at which point the main timer is started on a 24 hour loop.
*/
public static function startMotd() {
var now = Date.now();
var nextPost = new Date(now.getFullYear(), now.getMonth(), now.getDate(), settings.motd.time, 0, 0);
@ -379,8 +381,9 @@ class Onequestionmark {
/**
* Sends the MOTD to the channels specified in the bot settings. May just move this code into the places it's needed instead of keeping this function.
*/
* Sends the MOTD to the channels specified in the bot settings.
* May just move this code into the places it's needed instead of keeping this function.
*/
public static function postMotd() {
var msg = getMotd();
var channels:Array<String> = settings.motd.channels; // Because it won't let me do this directly
@ -390,8 +393,8 @@ class Onequestionmark {
/**
* This function checks the MOTD database to find the entry most relevant to the current date and returns the appropriate data.
*/
* This function checks the MOTD database to find the entry most relevant to the current date and returns the appropriate data.
*/
public static function getMotd() {
var msg = "";
var day:Array<String> = [];
@ -424,10 +427,10 @@ class Onequestionmark {
/**
* The `saveSystem()` function handles all filesystem writes. When the bot needs to save a file, it pushes data to the `saveQueue` array.
* The save system checks the queue regularly and operates on the first entry provided.
* This throttles filesystem access, to prevent multiple commands from writing to the drive at the same time.
*/
* The `saveSystem()` function handles all filesystem writes. When the bot needs to save a file, it pushes data to the `saveQueue` array.
* The save system checks the queue regularly and operates on the first entry provided.
* This throttles filesystem access, to prevent multiple commands from writing to the drive at the same time.
*/
public static function saveSystem() {
Timer.delay(function() {
saveTimer = new Timer(60*1000);
@ -448,24 +451,24 @@ class Onequestionmark {
/**
* Writes the modified `settings.json` from memory back to the drive.
*/
* Writes the modified `settings.json` from memory back to the drive.
*/
public static function saveSettings() {
File.saveContent("settings.json", Json.stringify(settings, "\t"));
}
/**
* Writes the modified `echobox-db.json` from memory back to the drive.
*/
* Writes the modified `echobox-db.json` from memory back to the drive.
*/
public static function saveEchoboxDB() {
File.saveContent("echobox-db.json", Json.stringify(echoboxDB, "\t"));
}
/**
* Performs a clean shutdown of the bot, after saving relevant files to the disk.
*/
* Performs a clean shutdown of the bot, after saving relevant files to the disk.
*/
public static function shutdown() {
saveSettings();
saveEchoboxDB();

View File

@ -59,4 +59,4 @@ onequestionmark is designed and tested to run in [NekoVM](https://nekovm.org/dow
`onequestionmark.n` should be placed in the same directory as its JSON files.
It is preferable to stop the bot via its own `?stop` command in Discord, so it can save its settings file before exiting.
It is preferable to stop the bot via its own `?quit` command in Discord, so it can save its settings file before exiting.