Compare commits
3 Commits
2035710bf7
...
v1.1
Author | SHA1 | Date | |
---|---|---|---|
22342d954f | |||
a36c40daf6 | |||
4c4013612e |
@@ -78,7 +78,12 @@ class Onequestionmark {
|
|||||||
public static function onReady() {
|
public static function onReady() {
|
||||||
Sys.sleep(1);
|
Sys.sleep(1);
|
||||||
Sys.println('[${timestamp()}] Bot is online');
|
Sys.println('[${timestamp()}] Bot is online');
|
||||||
//Endpoints.sendMessage(settings.devchannel, {content:"onequestionmark-chat alpha test is now running"}, null, false);
|
|
||||||
|
// Join message from program args
|
||||||
|
if (Sys.args().length > 0) {
|
||||||
|
Endpoints.sendMessage(settings.devchannel, {content:Sys.args().join(" ")}, null, false);
|
||||||
|
}
|
||||||
|
|
||||||
botInfo = Endpoints.getCurrentUser();
|
botInfo = Endpoints.getCurrentUser();
|
||||||
|
|
||||||
MainLoop.add(motd);
|
MainLoop.add(motd);
|
||||||
@@ -89,10 +94,13 @@ class Onequestionmark {
|
|||||||
// DevMode check
|
// DevMode check
|
||||||
if ((!settings.devmode) || (m.guild_id == settings.devserver)) {
|
if ((!settings.devmode) || (m.guild_id == settings.devserver)) {
|
||||||
var msg = m.content;
|
var msg = m.content;
|
||||||
|
var sender:String;
|
||||||
|
if (m.getMember().nick == null) {sender = m.author.global_name;} else {sender = m.getMember().nick;}
|
||||||
|
|
||||||
// Command processor
|
// Command processor
|
||||||
if (msg.charAt(0) == "?") {
|
if (msg.charAt(0) == "?") {
|
||||||
var command = "";
|
var command = "";
|
||||||
|
var args:Array<String> = [];
|
||||||
|
|
||||||
if (msg.indexOf(" ") != -1) {
|
if (msg.indexOf(" ") != -1) {
|
||||||
// Separate command from rest of message, if necessary
|
// Separate command from rest of message, if necessary
|
||||||
@@ -104,6 +112,12 @@ class Onequestionmark {
|
|||||||
msg = "";
|
msg = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Separate arguments from command
|
||||||
|
if (command.indexOf(".") != -1) {
|
||||||
|
args = command.substring(command.indexOf(".")+1).toLowerCase().split(".");
|
||||||
|
command = command.substring(0, command.indexOf(".")).toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
switch (command) {
|
switch (command) {
|
||||||
// Commands that require authorization
|
// Commands that require authorization
|
||||||
case "quit":
|
case "quit":
|
||||||
@@ -140,14 +154,112 @@ class Onequestionmark {
|
|||||||
}
|
}
|
||||||
// Basic response commands
|
// Basic response commands
|
||||||
case "help":
|
case "help":
|
||||||
m.reply({content:'
|
/*m.reply({content:'
|
||||||
**onequestionmark bot commands**\n`?chk`: ack\n`?slap <target>`: The classic mIRC troutslap.\n`?hug <target (optional)>`: Posts randomized hug image.\n`?yes` and `?no`: Posts randomized yes/no.\n`?angery`\n`?subway`\n`?motd`: Enables MOTD for current channel (requires auth)\n`?devmode`: Toggles Dev Mode (requires auth)\n`?quit`: Shutdown command (requires auth)\n**Non-command bot functions:**\n*MOTD*: Bot will post a randomized *Meme of the Day* in enabled channels.\n*Icce*: Bot provides users with ice cuboids.\n*Meteor*: Bot reacts to falling rocks in the chat.'}, false);
|
**onequestionmark bot commands**\n`?chk`: ack\n`?slap <target>`: The classic mIRC troutslap.\n`?hug <target (optional)>`: Posts randomized hug image.\n`?yes` and `?no`: Posts randomized yes/no.\n`?angery`\n`?subway`\n`?motd`: Enables MOTD for current channel (requires auth)\n`?devmode`: Toggles Dev Mode (requires auth)\n`?quit`: Shutdown command (requires auth)\n**Non-command bot functions:**\n*MOTD*: Bot will post a randomized *Meme of the Day* in enabled channels.\n*Icce*: Bot provides users with ice cuboids.\n*Meteor*: Bot reacts to falling rocks in the chat.'}, false);*/
|
||||||
|
m.reply({embeds: [
|
||||||
|
{
|
||||||
|
"color": 13733022,
|
||||||
|
"url": "https://discord.com",
|
||||||
|
"author": {
|
||||||
|
"name": "onequestionmark help",
|
||||||
|
"url": "https://discord.com",
|
||||||
|
"icon_url": "https://cdn.discordapp.com/avatars/1071524991084015756/d623b45d33e8119599b29c5cf5ed532e.png"
|
||||||
|
},
|
||||||
|
"thumbnail": {
|
||||||
|
"url": "https://cdn.discordapp.com/emojis/1071560243051511808.png"
|
||||||
|
},
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "**Bot commands:**",
|
||||||
|
"value": "`?help`: Posts this help document. :book:\n`?chk`: Replies with \"ack\". :speaking_head:\n`?slap <target>`: The classic mIRC troutslap. :fish:\n`?hug <target (optional)>`: Posts randomized hug image. :people_hugging:\n`?yes`: Posts randomized \"yes\" image or video. :thumbsup:\n`?no`: Posts randomized \"no\" image or video. :no_entry_sign:\n`?mrkrabs`: Similar to `?chk`. :crab:\n`?tufac`: The official Tufac Theme Song. :busts_in_silhouette:\n`?coin <count (optional)>`: Flips between 1 and 100 coins. :coin:\n`?dice.<arg> <num>`: Rolls <arg>-sided die <num> times :game_die:\n`?8ball`: Answers your yes or no questions. :8ball:\n`?echobox`: Posts randomized quote from the quote database. :loudspeaker:\n`?echobox <quote>`: Adds provided quote to the database. :writing_hand:",
|
||||||
|
"inline": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "**Basic Response Aliases:**",
|
||||||
|
"value": "`?angery`: *I taste a vegetal.* :rage:\n`?subway`: Arin's infamous Subway rant. :sandwich:\n`?illuminati`: Always watching. :eye:\n`?cube`: *The Cube*\n`?coolsville`: Population: Us :sunglasses:\n`?communism`: The old 3D rotating gif.\n`?opinions`: Here they come. :scream:",
|
||||||
|
"inline": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "**Auth-Requiring Commands:**",
|
||||||
|
"value": "`?motd`: Enables MOTD for current channel\n`?devmode`: Toggles Dev Mode\n`?quit`: Shutdown command",
|
||||||
|
"inline": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "**Non-command bot functions:**",
|
||||||
|
"value": "**MOTD**: *Meme of the Day* is posted in enabled channels.\n**Icce**: Bot provides users with ice cuboids. :ice_cube:",
|
||||||
|
"inline": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]});
|
||||||
case "chk":
|
case "chk":
|
||||||
m.reply({content:'<@${m.author.id}>: ack'}, false);
|
m.reply({content:'<@${m.author.id}>: ack'}, false);
|
||||||
case "mrkrabs":
|
case "mrkrabs":
|
||||||
m.reply({content:'<@${m.author.id}>: ack ack ack ack ack'}, false);
|
m.reply({content:'<@${m.author.id}>: ack ack ack ack ack'}, false);
|
||||||
case "slap":
|
case "slap":
|
||||||
if (msg.length != 0) {m.reply({content:'*onequestionmark slaps ${msg} around a bit with a large trout*'}, false);}
|
if (msg.length != 0) {m.reply({content:'*onequestionmark slaps ${msg} around a bit with a large trout*'}, false);}
|
||||||
|
case "tufac":
|
||||||
|
m.reply({content:"*Not Teh Face, but better,*\n*Tufac to the letter!*\n*Always two faces, never one,*\n*Tufac has you on the run!*"}, false);
|
||||||
|
// Gaming functions
|
||||||
|
case "coin":
|
||||||
|
if ((msg.length == 0) || (Std.parseInt(msg) == null) || (Std.parseInt(msg) == 1)) {
|
||||||
|
var coin = randInt(0,1);
|
||||||
|
if (coin == 1) {
|
||||||
|
m.reply({content:'${sender} flipped a coin and got heads.'}, false);
|
||||||
|
} else {
|
||||||
|
m.reply({content:'${sender} flipped a coin and got tails.'}, false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ((Std.parseInt(msg) > 1) && (Std.parseInt(msg) < 101)) {
|
||||||
|
var heads:Int = 0;
|
||||||
|
for (i in 1...(Std.parseInt(msg)+1)) {
|
||||||
|
heads += randInt(0,1);
|
||||||
|
}
|
||||||
|
m.reply({content:'${sender} flipped ${Std.parseInt(msg)} coins.\n**Heads:** ${heads}\n**Tails:** ${Std.parseInt(msg)-heads}'}, false);
|
||||||
|
} else {
|
||||||
|
m.reply({content:'Please enter a value between 1 and 100.'}, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case "dice":
|
||||||
|
var sides:Int = 6;
|
||||||
|
|
||||||
|
// Set number of sides
|
||||||
|
if (args.length != 0) {
|
||||||
|
if (Std.parseInt(args[0]) != null) {
|
||||||
|
sides = Std.parseInt(args[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate sides
|
||||||
|
if (sides == 1) {
|
||||||
|
m.reply({content:'${sender} rolled a ball or something, idk.'}, false);
|
||||||
|
} else if (sides == 2) {
|
||||||
|
m.reply({content:'${sender} tried to roll a 2-sided die (this is called a coin btw).'}, false);
|
||||||
|
} else if ((sides < 1) || (sides > 100)) {
|
||||||
|
m.reply({content:'Please enter a value between 1 and 100.'}, false);
|
||||||
|
} else {
|
||||||
|
// Roll a single die
|
||||||
|
if ((msg.length == 0) || (Std.parseInt(msg) == null) || (Std.parseInt(msg) == 1)) {
|
||||||
|
m.reply({content:'${sender} rolled a ${sides}-sided die and got ${randInt(1,sides)}.'}, false);
|
||||||
|
} else {
|
||||||
|
// Roll multiple dice
|
||||||
|
if ((Std.parseInt(msg) > 1) && (Std.parseInt(msg) < 101)) {
|
||||||
|
var results:Array<Int> = [];
|
||||||
|
for (i in 1...(Std.parseInt(msg)+1)) {
|
||||||
|
results.push(randInt(1,sides));
|
||||||
|
}
|
||||||
|
// Sort results high-to-low
|
||||||
|
results.sort((a, b) -> b - a);
|
||||||
|
|
||||||
|
m.reply({content:'${sender} rolled a ${sides}-sided die ${Std.parseInt(msg)} times.\n**Results:** ${results.toString()}'}, false);
|
||||||
|
} else {
|
||||||
|
m.reply({content:'Please enter a value between 1 and 100.'}, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case "8ball":
|
||||||
|
var response:Array<String> = ["It is certain.","It is decidedly so.","Without a doubt.","Yes definitely.","You may rely on it.","As I see it, yes.","Most likely.","Outlook good.","Yes.","Signs point to yes.","Reply hazy, try again.","Ask again later.","Better not tell you now.","Cannot predict now.","Concentrate and ask again.","Don't count on it.","My reply is no.","My sources say no.","Outlook not so good.","Very doubtful."];
|
||||||
|
m.reply({content:'🎱 ${response[randInt(0,19)]} 🎱'}, false);
|
||||||
// Basic aliases
|
// Basic aliases
|
||||||
case "angery":
|
case "angery":
|
||||||
m.reply({content:"https://cdn.discordapp.com/attachments/1071547517847732305/1079518504413311108/angery.jpg"}, false);
|
m.reply({content:"https://cdn.discordapp.com/attachments/1071547517847732305/1079518504413311108/angery.jpg"}, false);
|
||||||
@@ -159,10 +271,10 @@ class Onequestionmark {
|
|||||||
m.reply({content:"https://cdn.discordapp.com/attachments/270113422232911883/502690458779123722/the_cube.jpg"}, false);
|
m.reply({content:"https://cdn.discordapp.com/attachments/270113422232911883/502690458779123722/the_cube.jpg"}, false);
|
||||||
case "coolsville":
|
case "coolsville":
|
||||||
m.reply({content:"https://cdn.discordapp.com/attachments/1071547517847732305/1147583765212835921/coolsville.gif"}, false);
|
m.reply({content:"https://cdn.discordapp.com/attachments/1071547517847732305/1147583765212835921/coolsville.gif"}, false);
|
||||||
case "tufac":
|
|
||||||
m.reply({content:"*Not Teh Face, but better,*\n*Tufac to the letter!*\n*Always two faces, never one,*\n*Tufac has you on the run!*"}, false);
|
|
||||||
case "communism":
|
case "communism":
|
||||||
m.reply({content:"https://cdn.discordapp.com/attachments/1071547517847732305/1147590229960691742/communism.gif"}, false);
|
m.reply({content:"https://cdn.discordapp.com/attachments/1071547517847732305/1147590229960691742/communism.gif"}, false);
|
||||||
|
case "opinions":
|
||||||
|
m.reply({content:"https://cdn.discordapp.com/attachments/1071547517847732305/1147983375701921892/opinions.jpg"}, false);
|
||||||
// Image database commands
|
// Image database commands
|
||||||
case "hug":
|
case "hug":
|
||||||
m.reply({content:'🫂 *hugs ${msg}*\n${hugDB[randInt(0, hugDB.length-1)]}'}, false);
|
m.reply({content:'🫂 *hugs ${msg}*\n${hugDB[randInt(0, hugDB.length-1)]}'}, false);
|
||||||
@@ -183,13 +295,11 @@ class Onequestionmark {
|
|||||||
var quote:String = "";
|
var quote:String = "";
|
||||||
|
|
||||||
// Echobox response
|
// Echobox response
|
||||||
if (!m.mention_everyone) {
|
if ((!m.mention_everyone) && (m.mentions.length == 0) && (m.mention_roles.length == 0)) {
|
||||||
if (echobox.length > 0) {
|
if (echobox.length > 0) {
|
||||||
var ebchoice = randInt(0, echobox.length-1);
|
var ebchoice = randInt(0, echobox.length-1);
|
||||||
//m.reply({content:'**Echobox, quote #${ebchoice+1}:** ${echobox[ebchoice]}'}, false);
|
|
||||||
quote = '**Echobox, quote #${ebchoice+1}:** ${echobox[ebchoice]}';
|
quote = '**Echobox, quote #${ebchoice+1}:** ${echobox[ebchoice]}';
|
||||||
} else {
|
} else {
|
||||||
//m.reply({content:'**Echobox:** There are no quotes in this server\'s Echobox yet.'}, false);
|
|
||||||
quote = '**Echobox:** There are no quotes in this server\'s Echobox yet.';
|
quote = '**Echobox:** There are no quotes in this server\'s Echobox yet.';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,7 +317,7 @@ class Onequestionmark {
|
|||||||
m.reply({content:quote}, false);
|
m.reply({content:quote}, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m.reply({content:'**Echobox:** You cannot add `@everyone` to the Echobox.'}, false);
|
m.reply({content:'**Echobox:** You cannot add mentions to the Echobox.'}, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user