Added command processor
This commit is contained in:
parent
b74b3a12b6
commit
b117f9f4f4
@ -30,9 +30,55 @@ class Onequestionmark {
|
|||||||
|
|
||||||
public static function onReady() {
|
public static function onReady() {
|
||||||
Sys.println("onequestionmark is online.");
|
Sys.println("onequestionmark is online.");
|
||||||
Endpoints.sendMessage(settings.devchannel, {content:"onequestionmark-chat alpha test is now running"}, null, false);
|
//Endpoints.sendMessage(settings.devchannel, {content:"onequestionmark-chat alpha test is now running"}, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function onMessageCreate(m:Message) {
|
public static function onMessageCreate(m:Message) {
|
||||||
|
// DevMode check
|
||||||
|
if ((!settings.devmode) || (m.guild_id == settings.devserver)) {
|
||||||
|
var msg = m.content;
|
||||||
|
|
||||||
|
// Command processor
|
||||||
|
if (msg.charAt(0) == "?") {
|
||||||
|
var command = "";
|
||||||
|
|
||||||
|
if (msg.indexOf(" ") != -1) {
|
||||||
|
// Separate command from rest of message, if necessary
|
||||||
|
command = msg.substring(1, msg.indexOf(" ")).toLowerCase();
|
||||||
|
msg = msg.substring(msg.indexOf(" ")+1);
|
||||||
|
} else {
|
||||||
|
// Otherwise, remove msg
|
||||||
|
command = msg.substring(1).toLowerCase();
|
||||||
|
msg = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (command) {
|
||||||
|
// Commands that require authorization
|
||||||
|
case "quit":
|
||||||
|
if (m.author.id == settings.botowner) {
|
||||||
|
m.reply({content:"Shutdown command received from botowner, exiting."}, false);
|
||||||
|
Sys.println("Shutdown command received from botowner, exiting.");
|
||||||
|
Sys.exit(0);
|
||||||
|
}
|
||||||
|
// System for WIP commands that only work in testing server
|
||||||
|
case "wipcommand":
|
||||||
|
if (m.guild_id == settings.devserver) {
|
||||||
|
m.reply({content:"Dev Server response."}, true);
|
||||||
|
}
|
||||||
|
// Basic response commands
|
||||||
|
case "chk":
|
||||||
|
m.reply({content:'<@${m.author.id}>: ack'}, false);
|
||||||
|
case "slap":
|
||||||
|
if (msg.length != 0) {m.reply({content:'*onequestionmark slaps ${msg} around a bit with a large trout*'}, false);}
|
||||||
|
case "angery":
|
||||||
|
m.reply({content:"https://cdn.discordapp.com/attachments/1071547517847732305/1079518504413311108/angery.jpg"}, false);
|
||||||
|
case "subway":
|
||||||
|
m.reply({content:"https://www.youtube.com/watch?v=y3VRXVvr6XU"}, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Non-command responses
|
||||||
|
if ((msg.charAt(0) == ".") && (msg.length == 1)) {m.reply({content:"omg a meteor"}, true);}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
-m Onequestionmark
|
-m Onequestionmark
|
||||||
-L hxdiscord
|
-L hxdiscord
|
||||||
#-D no-deprecation-warnings
|
# hxdiscord uses deprecated functions
|
||||||
|
-D no-deprecation-warnings
|
||||||
--hl export/onequestionmark.hl
|
--hl export/onequestionmark.hl
|
||||||
--cmd hl export/onequestionmark.hl
|
--cmd hl export/onequestionmark.hl
|
Loading…
x
Reference in New Issue
Block a user