Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #5 from AtiLion/recode
Browse files Browse the repository at this point in the history
Pushed the recode
  • Loading branch information
AtiLion authored Aug 28, 2019
2 parents 8eaac19 + b7c63b7 commit 3903f0e
Show file tree
Hide file tree
Showing 26 changed files with 912 additions and 760 deletions.
883 changes: 534 additions & 349 deletions BotNeck.plugin.js

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions BotNeckModules/_8ball.botneck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
class _8ball {
constructor() {
this.permissions = [];
this.command = "8ball";
this.description = "The magic 8ball will answer any of your questions(as long as they are a yes or no question)";
this.usage = "8ball [question]";

this.answers = ["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."];
}

execute(message, args) {
// Init
delete message["content"];

// Validate number of args
if(BotNeckAPI.getArgumentNumber(args) < 1)
return message["embed"] = BotNeckAPI.generateError("You need at least 1 argument for this command!");

// Get input
let input = BotNeckAPI.getArgumentsAsString(args);

// Execute
message["embed"] = {
title: "Magic 8Ball",
type: "rich",
description: "",
color: 0x0061ff,
fields: [
{
name: "Question",
value: input,
},
{
name: "Answer",
value: this.answers[Math.floor(Math.random() * this.answers.length)],
},
]
}
}
}
60 changes: 60 additions & 0 deletions BotNeckModules/backupChat.botneck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
const path = require("path");

class backupChat {
constructor() {
this.permissions = [ "authorized_request" ];
this.command = "backupChat";
this.description = "Backs up the specified amount of chat into a file";
this.usage = "backup [amount of messages] [file name]";
}

execute(message, args) {
// Init
delete message["content"];

// Validate number of args
if(BotNeckAPI.getArgumentNumber(args) < 2)
return message["embed"] = BotNeckAPI.generateError("You need at least 2 arguments for this command!");
if(isNaN(args[0]))
return message["embed"] = BotNeckAPI.generateError("Specified argument is not a number!");
if(Number(args[0]) < 0 || Number(args[0]) > 100)
return message["embed"] = BotNeckAPI.generateError("Message number can't be lower than 0 and higher than 100!");

// Backup
$.ajax({
type: "GET",
url: "https://discordapp.com/api/v6/channels/" + BotNeckAPI.getCurrentChannelId() + "/messages?limit=" + args[0],
dataType: "json",
contentType: "application/json",
beforeSend: function (xhr) { BotNeckAPI.setAuthHeader(xhr, APIKey); },
success: function(data)
{
let chatBackup = path.join(window.bdConfig.dataPath, "Chat_Backup");

if(!fs.existsSync(chatBackup))
fs.mkdirSync(chatBackup);

let save = "";
for(let i in data)
{
if(!data[i].hasOwnProperty("content") || data[i].content == "")
continue;
save += data[i].author.username + "#" + data[i].author.discriminator + ": " + data[i].content + "\n";
}

if(fs.existsSync(chatBackup + "/" + args[1] + ".log")) {
fs.unlink(chatBackup + "/" + args[1] + ".log", () => { fs.writeFile(chatBackup + "/" + args[1] + ".log", save, () => {}); });
return;
}
fs.writeFile(chatBackup + "/" + args[1] + ".log", save, () => {});
}
});

message["embed"] = {
title: "Chat Backup",
type: "rich",
description: "Chat backed up successfully!",
color: 0x0061ff
}
}
}
38 changes: 38 additions & 0 deletions BotNeckModules/calc.botneck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
class calc {
constructor() {
this.permissions = [];
this.command = "calc";
this.description = "This will calculate anything for you";
this.usage = "calc [calculation]";
}

execute(message, args) {
// Init
delete message["content"];

// Validate number of args
if(BotNeckAPI.getArgumentNumber(args) < 1)
return message["embed"] = BotNeckAPI.generateError("You need at least 1 argument for this command!");

// Get input
let input = BotNeckAPI.getArgumentsAsString(args);

// Execute
message["embed"] = {
title: "Calculator",
type: "rich",
description: "",
color: 0x0061ff,
fields: [
{
name: "Calculation",
value: input,
},
{
name: "Result",
value: eval(input),
},
]
}
}
}
35 changes: 35 additions & 0 deletions BotNeckModules/choose.botneck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
class choose {
constructor() {
this.permissions = [];
this.command = "choose";
this.description = "Randomly choose an answer";
this.usage = "choose [answer1, answer2, answer3, ...]";
}

execute(message, args) {
// Init
delete message["content"];

// Validate number of args
if(BotNeckAPI.getArgumentNumber(args) < 2)
return message["embed"] = BotNeckAPI.generateError("You need at least 2 arguments for this command!");

// Setup inputs
let input = BotNeckAPI.getArgumentsAsString(args);
let choices = input.split(",");

// Execute
message["embed"] = {
title: "Random Chooser",
type: "rich",
description: "I choose: " + choices[Math.floor(Math.random() * choices.length)].trim(),
color: 0x0061ff,
fields: [
{
name: "Choices",
value: input,
}
]
}
}
}
File renamed without changes.
31 changes: 31 additions & 0 deletions BotNeckModules/flip.botneck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class flip {
constructor() {
this.permissions = [];
this.command = "flip";
this.description = "Flip the text";
this.usage = "flip [text]";

this.char_list = "abcdefghijklmnpqrtuvwxyzABCDEFGHIJKLMNPQRTUVWYZ12345679!&*(),.'";
this.alt_char_list = "ɐqɔpǝɟƃɥᴉɾʞlɯudbɹʇnʌʍxʎz∀qƆpƎℲפHIſʞ˥WNԀQɹ┴∩ΛM⅄ZƖᄅƐㄣϛ9ㄥ6¡⅋*)('˙,";
}

execute(message, args) {
// Validate number of args
if(BotNeckAPI.getArgumentNumber(args) < 1)
return message["embed"] = BotNeckAPI.generateError("You need at least 1 arguments for this command!");

// Get input
let input = BotNeckAPI.getArgumentsAsString(args);

// Flip
message.content = "";
for(let i = 0; i < input.length; i++) {
let index = this.char_list.indexOf(input[i]);

if(index < 0)
message.content += input[i];
else
message.content += this.alt_char_list[index];
}
}
}
12 changes: 12 additions & 0 deletions BotNeckModules/lenny.botneck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class lenny {
constructor() {
this.permissions = [];
this.command = "lenny";
this.description = "Displays a lenny face";
this.usage = "lenny";
}

execute(message, args) {
message.content = "( ͡° ͜ʖ ͡°)";
}
}
19 changes: 19 additions & 0 deletions BotNeckModules/lmgtfy.botneck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class lmgtfy {
constructor() {
this.permissions = [];
this.command = "lmgtfy";
this.description = "Creates a lmgtfy link for people who can't google";
this.usage = "lmgtfy [what to google]";

this.url = "http://lmgtfy.com/?q=";
}

execute(message, args) {
// Validate number of args
if(BotNeckAPI.getArgumentNumber(args) < 1)
return message["embed"] = BotNeckAPI.generateError("You need at least 1 argument for this command!");

// Generate link
message.content = this.url + encodeURI(BotNeckAPI.getArgumentsAsString(args));
}
}
53 changes: 53 additions & 0 deletions BotNeckModules/love.botneck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
class love {
constructor() {
this.permissions = [];
this.command = "love";
this.description = "Calculates the love between 2 users <3";
this.usage = "love <user1> [user2]";
}

execute(message, args) {
// Init
delete message["content"];

// Validate number of args
if(BotNeckAPI.getArgumentNumber(args) < 2)
return message["embed"] = BotNeckAPI.generateError("You need at least 2 argument for this command!");

// Setup variables
let user1 = args[0];
let user2 = args[1];
let txt = user1 + user2;
let process_num = "";
let processed_num = "";

// Calculate
process_num = (txt.match(/l/gi) || []).length.toString() + (txt.match(/o/gi) || []).length.toString() + (txt.match(/v/gi) || []).length.toString() + (txt.match(/e/gi) || []).length.toString() + (txt.match(/s/gi) || []).length.toString();
while(process_num.length > 2)
{
for(let i = 0; i < process_num.length - 1; i++)
processed_num += (Number(process_num[i]) + Number(process_num[i + 1])).toString();

process_num = processed_num;
processed_num = "";
}

// Cheat
if(args["cheat"])
process_num = args["cheat"];

// Display
message["embed"] = {
title: "Love Calculator",
type: "rich",
description: `How much do ${user1} and ${user2} love each other?`,
color: 0x0061ff,
fields: [
{
name: "Result",
value: process_num + "%",
},
]
};
}
}
File renamed without changes.
49 changes: 49 additions & 0 deletions BotNeckModules/regional.botneck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
class regional {
constructor() {
this.permissions = [];
this.command = "regional";
this.description = "Changes all letters into regionals";
this.usage = "regional [text]";

this.regionals = {'a': ':regional_indicator_a:', 'b': ':regional_indicator_b:',
'c': ':regional_indicator_c:',
'd': ':regional_indicator_d:', 'e': ':regional_indicator_e:',
'f': ':regional_indicator_f:',
'g': ':regional_indicator_g:', 'h': ':regional_indicator_h:',
'i': ':regional_indicator_i:',
'j': ':regional_indicator_j:', 'k': ':regional_indicator_k:',
'l': ':regional_indicator_l:',
'm': ':regional_indicator_m:', 'n': ':regional_indicator_n:',
'o': ':regional_indicator_o:',
'p': ':regional_indicator_p:', 'q': ':regional_indicator_q:',
'r': ':regional_indicator_r:',
's': ':regional_indicator_s:', 't': ':regional_indicator_t:',
'u': ':regional_indicator_u:',
'v': ':regional_indicator_v:', 'w': ':regional_indicator_w:',
'x': ':regional_indicator_x:',
'y': ':regional_indicator_y:', 'z': ':regional_indicator_z:',
'0': '0⃣', '1': '1⃣', '2': '2⃣', '3': '3⃣',
'4': '4⃣', '5': '5⃣', '6': '6⃣', '7': '7⃣', '8': '8⃣', '9': '9⃣', '!': '\u2757',
'?': '\u2753', ' ': ' '}

}

execute(message, args) {
// Validate number of args
if(BotNeckAPI.getArgumentNumber(args) < 1)
return message["embed"] = BotNeckAPI.generateError("You need at least 1 argument for this command!");

// Get input
let input = BotNeckAPI.getArgumentsAsString(args);

// Execute
message.content = "";
for(let i = 0; i < input.length; i++)
{
if(this.regionals[input[i].toLowerCase()])
message.content += this.regionals[input[i].toLowerCase()] + "\u200b";
else
message.content += input[i];
}
}
}
28 changes: 28 additions & 0 deletions BotNeckModules/roll.botneck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class roll {
constructor() {
this.permissions = [];
this.command = "roll";
this.description = "Rolls the dice";
this.usage = "roll [max value]";
}

execute(message, args) {
// Init
delete message["content"];

// Validate number of args
if(BotNeckAPI.getArgumentNumber(args) < 1)
return message["embed"] = BotNeckAPI.generateError("You need at least 1 argument for this command!");
if(isNaN(args[0]))
return message["embed"] = BotNeckAPI.generateError("Specified argument is not a number!");

// Execute
let num = Math.floor(Math.random() * Number(args[0]) + 1);
message["embed"] = {
title: "Roll the dice",
type: "rich",
description: "The dice rolled a " + num + " with the maximum value of " + args[0],
color: 0x0061ff,
}
}
}
Loading

0 comments on commit 3903f0e

Please sign in to comment.