Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
- All commands are now in a command handler (#59)
Browse files Browse the repository at this point in the history
- Language changes, some mistake are now deleted
- Bugs and stability fix
- Added the package fs in package.json
- The kappa image is now smaller, to not spend kappa everywhere and lord the world
- Removed the fake kappahd.png to let the real take over the world
- Credits command got some new people in it :)
  • Loading branch information
RisedSky authored Aug 9, 2018
1 parent fc56a13 commit 54b3ee0
Show file tree
Hide file tree
Showing 39 changed files with 1,880 additions and 1,476 deletions.
69 changes: 69 additions & 0 deletions commands/bot-info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
module.exports = {
help: { name: "bot-info" },
run: async (call) => {
var message = call.message
, Mess_Member = call.message.member
, Discord = require("discord.js")
//message, bot, bot.commands, args, content, prefix, cmd

try {
var d = new Date(null);
d.setMilliseconds(call.bot.uptime);
var bot_online_since_time = d.toISOString().substr(11, 8); // récupere le temps et le transforme en HH:mm:ss

var time = call.bot.moment.duration(call.bot.uptime, "milliseconds");
//console.log(bot.uptime);

var time_string;
if (time.get("days") > 1) {
time_string = time.get("days") + " days, " + time.get("hours") + " hours, " + time.get("minutes") + " minutes, " + time.get("s") + " seconds."

} else if (time.get("hours") > 1) {
time_string = time.get("hours") + " hours, " + time.get("minutes") + " minutes, " + time.get("s") + " seconds."

} else if (time.get("minutes") > 1) {
time_string = time.get("minutes") + " minutes, " + time.get("s") + " seconds."

} else if (time.get("seconds") > 1) {
time_string = time.get("s") + " seconds."

}


//console.log(bot_online_since_time)
//var bot_online_since_time = moment(d).format("HH:mm:ss DD-MM-YYYY")
var bot_online_since_time = time_string
var bot_date_created = call.bot.moment(call.bot.user.createdTimestamp).format("HH:mm:ss DD-MM-YYYY");

var embedbot_info = new Discord.RichEmbed()
.setColor("#FFFFFF")
.setAuthor("Bot-Information", call.bot.user.avatarURL)
.setTitle("Created by RisedSky & PLfightX")
.addField("I'm developed in Node.js", "I'm using Discord.js libraries", true)
.addField("My node version", process.version, true)
.addBlankField()
.addField("Memory Usage", Math.floor(process.memoryUsage().heapUsed / 1024 / 1024 * 100 / 100) + " / " + Math.floor(process.memoryUsage().heapTotal / 1024 / 1024 * 100 / 100) + " Mb", true)
.addField("My version", call.bot.config.bot_version, true)
.addBlankField()
.addField("I am created since", bot_date_created, true)
.addField("I am online since", bot_online_since_time, true)
.addBlankField()
.addField("I am in", call.bot.guilds.size + " servers", true)
.addField("With", call.bot.users.size + " users", true)
//.setFooter("Asked by " + message.author.username + "")
.setFooter(call.bot.AskedBy_EmbedFooter(message.author))
.setTimestamp();
//.addField("")
//liste des bêta-testers
message.channel.send(embedbot_info).then(function (msg) {
call.bot.deleteMyMessage(msg, 300 * 1000)
})


} catch (error) {
console.log("bot-info error");
console.log(error);

}
}
}
29 changes: 29 additions & 0 deletions commands/credits.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = {
help: { name: "credits" },
run: async (call) => {
var message = call.message
, Mess_Member = call.message.member
, Discord = require("discord.js")
//message, bot, bot.commands, args, content, prefix, cmd


try {
var embed_credits = new Discord.RichEmbed()
.setAuthor(call.bot.user.username, call.bot.user.avatarURL)
.setColor("ORANGE")
.setDescription(
"A big thanks to:\n" +
"`gt-c#0495` for the big help in contributing to the bot in github & in DM\n\n" +
"`Amoky#2264` & `Pyrothec06#1012` - For the french translation\n\n" +
"`Showehanle2000#9772` - For the russian translation\n\n" +
"\nSpecial thanks: \n\n" +
"`Sloper39#9509` & `Tard0sTV#8871` - For being so active in our server !\n\n" +
"`KoyLL_#7806, ilian0112#4033, X-ray984589#8466, Arnor Leaderlight#3895, Sheltai#9181` - For testing the bot"
)
message.channel.send(embed_credits)
} catch (error) {
console.log("credits error");
console.log(error);
}
}
}
43 changes: 43 additions & 0 deletions commands/eval.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module.exports = {
help: { name: "eval" },
run: async (call) => {
var message = call.message
, Mess_Member = call.message.member
, Mess_Channel = call.message.channel
, Discord = require("discord.js")
//message, bot, bot.commands, args, content, prefix, cmd


try {
call.bot.DeleteUserMessage(false)
let owner_list = "145632403946209280 - 268813812281376769";
if (!owner_list.includes(message.author.id)) return;
if (!message.author.username == "RisedSky" || !message.author.username == "PLfightX") return;
if (!message.author.discriminator == "1250" || !message.author.discriminator == "8625") return;

function clean(text) {
if (typeof (text) === "string")
return text.replace(/`/g, "`" + String.fromCharCode(8203)).replace(/@/g, "@" + String.fromCharCode(8203));
else
return text;
}

try {
const code = call.content;
let evaled = eval(code);

if (typeof evaled !== "string")
evaled = require("util").inspect(evaled);

message.channel.send(clean(evaled), { code: "xl", split: true });
} catch (err) {
message.channel.send(`\`ERROR\` \`\`\`xl\n${clean(err)}\n\`\`\``);
}

} catch (error) {
console.log("eval error");
console.log(error)
}

}
}
16 changes: 16 additions & 0 deletions commands/github.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
help: { name: "github" },
run: async (call) => {
var message = call.message
, Mess_Member = call.message.member
, Mess_Channel = call.message.channel
//message, bot, bot.commands, args, content, prefix, cmd

try {
call.bot.sendDMToUser(message, `${call.bot.current_lang.Command_Github_Project} : https://github.com/RisedSky/discordPandaJS`)
} catch (err) {
console.log("Github error")
console.log(err);
}
}
}
79 changes: 79 additions & 0 deletions commands/help.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
module.exports = {
help: { name: "help" },
run: async (call) => {
var message = call.message
, Mess_Member = call.message.member
//message, bot, bot.commands, args, content, prefix, cmd

try {
var help_msgToSend_summary = ("```fix\n" +
"# » Created by RisedSky & PLfightX" + "\n" +
"# » And obviously helped by the bêta - testers.```" + "\n" +
"```dsconfig\n" +
"The prefix for the server " + message.guild.name + " is '" + call.bot.config.prefix + "'\n" +
"```\n")

var help_msgToSend_cmds = (
"```md\n" +
"<» Music Commands>\n\n" +
`#» ${call.bot.config.prefix}play [title / music's link]\nThe bot will join your channel and will play your music\n\n` +
`#» ${call.bot.config.prefix}play-list [playlist link]\nThe bot will join your channel and will play the playlist\n\n` +
`#» ${call.bot.config.prefix}pause\nThe bot pause the music (resume & pause included in)\n\n` +
`#» ${call.bot.config.prefix}search [title]\nSearch a music link (with embed info like ${call.bot.config.prefix}play)\n\n` +
`#» ${call.bot.config.prefix}skip\nThe bot will skip the current music\n\n` +
`#» ${call.bot.config.prefix}stop\nClear the queue and stop the music\n\n` +
`#» ${call.bot.config.prefix}queue\nShow the queue list\n\n` +
`#» ${call.bot.config.prefix}loop\nWill loop the currently song forever\n\n` +
`#» ${call.bot.config.prefix}status\nShow the status of the current song !` +
"```" +
"\n\n" + "```md\n" +
"<» Other Commands>\n\n\n" +
`#» [NEW COMMAND!!] ${call.bot.config.prefix}lang\nChange the language of the bot!\n\n` +
`#» ${call.bot.config.prefix}say [text]\nCommand to speak the bot (Need the perm 'MANAGE_MESSAGES'\n\n` +
`#» ${call.bot.config.prefix}github\nSend you my GitHub project in your DMs\n\n` +
`#» ${call.bot.config.prefix}ping\nShow the ping of the bot\n\n` +
`#» ${call.bot.config.prefix}purge [number]\nClear a selected number of messages (Max 100)\n\n` +
`#» ${call.bot.config.prefix}random-number [min_number] [max_number]\nGenerate a number between one and an another\n\n` +
//call.bot.config.prefix + "restart", "Redémarre le bot **(Expérimental**"
`#» ${call.bot.config.prefix}random-member\nRandomly choose one member of the server\n\n` +
`#» ${call.bot.config.prefix}poll [question | answer1 | answer2 | answer3 ... ]\nCreate a poll with a maximum of 9 answers\n\n` +
`#» ${call.bot.config.prefix}kappa\nSend a kappa image\n\n` +
`#» ${call.bot.config.prefix}rekt [@someone]\nRekt one of your friends\n\n` +
`#» ${call.bot.config.prefix}welcome\nSet a welcome message to your incredibleer !` +

"\n" + "```" +

"\n" +
"```md\n" +
`#» ${call.bot.config.prefix}bot-info\nSend you the information of the bot\n\n` +
`#» ${call.bot.config.prefix}server-info\nSend a lot of information about the currently server\n\n` +
`#» ${call.bot.config.prefix}user-info [@someone]\nGet secret informations about someone\n\n` +
`#» ${call.bot.config.prefix}verif-perms\nTell you about the perms I have in this channel\n\n` +
`#» ${call.bot.config.prefix}staff\nSend a message to my creators\n\n` +
`#» ${call.bot.config.prefix}invite\nGive you the invite link to add me !\n\n` +
`#» [NEW COMMAND!!] ${call.bot.config.prefix}credits\nCredits for people who helped us !\n\n` +
`#» ${call.bot.config.prefix}help\nShow all the bot commands (This message)!` +
"\n" +
"```" + "\n\n\n")

var help_msgToSend_channelTags = (

"```md\n" +
"<» Channel Tags>\n\n\n" +
"#» To use channel tags, just add the tags in a channel topic, it will be detected instantly\n\n" +
"#» <nocmds>\nAvoid the use of commands in the channel \n\n" +
"#» <ideas>\nWith this tag, the bot will add a upvote / downvote reaction to every message \n \n" +
"#» <autopurge:TIME:>\nDelete every message in the channel after TIME seconds" +
"```")

call.bot.sendDMToUser(message, help_msgToSend_summary)
call.bot.sendDMToUser(message, help_msgToSend_cmds)
call.bot.sendDMToUser(message, help_msgToSend_channelTags)

} catch (error) {
console.log("help error")
console.log(error);
}

}
}
20 changes: 20 additions & 0 deletions commands/invite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
help: { name: "invite" },
run: async (call) => {
var message = call.message
, Mess_Member = call.message.member
//message, bot, bot.commands, args, content, prefix, cmd

try {
message.author.createDM();
message.author.send("Hello, thanks for inviting me to your server\n\nHere is my link: https://discordapp.com/oauth2/authorize?&client_id=" + call.bot.user.id + "&scope=bot&permissions=8");
message.author.send("And here is the link of my official discord server: " + call.bot.Server_Link)
} catch (error) {
message.reply("Your DM are closed. I can't DM you :worried: ").then(function (msg) {
call.bot.deleteMyMessage(msg, 15 * 1000);
})
console.log("Invite error: " + error + " | User: " + message.author.username)
}

}
}
24 changes: 24 additions & 0 deletions commands/kappa.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
help: { name: "kappa" },
run: async (call) => {
var message = call.message
, Mess_Member = call.message.member
, Mess_Channel = call.message.channel
//message, bot, bot.commands, args, content, prefix, cmd


try {
message.reply({file:"./images/kappa.png"})
} catch (error) {
console.log("kappa error");
console.log(error);
}
/*
>use this only for deleting the msg after the image
.then(function (msg) {
deleteMyMessage(msg, 600 * 1000);
})
*/

}
}
83 changes: 83 additions & 0 deletions commands/lang.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
module.exports = {
help: { name: "lang" },
run: async (call) => {
var message = call.message
, Discord = require("discord.js")
//message, bot, bot.commands, args, content, prefix, cmd

/*call.bot.SQL_GetResult(function (err, result) {
if (err) console.log("Database error!");
if (result == undefined) return
lang = result.lang;
if (!call.args[0]) {
if (lang == undefined || lang == null || lang == "") {
return message.reply(`Current language: None`)
} else return message.reply(`Current language: ${result.lang}`)
*/

call.bot.SQL_GetResult(message, message.member)
.then(result => {
//console.log(result)
if (result == undefined) return
lang = result.lang;

//console.log(call.args);

if (!call.args[0]) {
if (lang == undefined || lang == null || lang == "") {
return message.reply(`Current language: None`)
} else return message.reply(`Current language: ${result.lang}`)


} else if (!call.bot.member_Has_MANAGE_GUILD) {
return message.reply(`${call.bot.current_lang.Command_User_Not_Allowed} ${call.bot.current_lang.Permission_Manage_Server_Required}`)
}

switch (call.args[0].toLowerCase()) {
case "help":
var lang_embed = new Discord.RichEmbed()
.setAuthor(call.bot.user.username, call.bot.user.avatarURL)
.setColor("GREEN")
.setDescription(
`Available language:\nFrench, English, Russian\n\nCommand to change the language: \`${call.bot.config.prefix}lang english\``
)
message.channel.send(lang_embed).then(msg => {
call.bot.deleteMyMessage(msg, 60 * 1000)
})
break;
case "french":
call.bot.SQL_UpdateLang(message, "lang", "french").then(() => {
setTimeout(() => {
message.reply(call.bot.current_lang.Lang_Defined_To_French)
}, 350);
})
break;

case "english":
call.bot.SQL_UpdateLang(message, "lang", "english").then(() => {
setTimeout(() => {
message.reply(call.bot.current_lang.Lang_Defined_To_English)
}, 350);
})
break;

case "russian":
call.bot.SQL_UpdateLang(message, "lang", "russian").then(() => {
setTimeout(() => {
message.reply(call.bot.current_lang.Lang_Defined_To_Russian)
}, 350);
})
break;
default:
message.reply(String(call.bot.current_lang.Lang_Didnt_Find_Lang).replace("{0}", call.args[0]))
message.reply(`The help command is: ${call.bot.config.prefix}lang help`)
break;
}

})
.catch(err => {
console.log(err)
})
}
}
Loading

0 comments on commit 54b3ee0

Please sign in to comment.