├── .gitignore ├── client └── player.js ├── events ├── ready.js ├── messageCreate.js └── interactionCreate.js ├── index.js ├── commands └── info │ └── ping.js ├── SlashCommands ├── fun │ ├── coinflip.js │ ├── advice.js │ └── 8ball.js ├── info │ ├── ping.js │ ├── stats.js │ └── info.js ├── music │ ├── skip.js │ ├── pause.js │ ├── resume.js │ ├── shuffle.js │ ├── seek.js │ ├── currentSong.js │ ├── queue.js │ ├── volume.js │ ├── play.js │ └── lyrics.js ├── images │ ├── cat.js │ ├── meme.js │ ├── xkcd.js │ └── pokemon.js ├── utility │ ├── clear.js │ └── rng.js ├── misc │ ├── ud.js │ └── define.js └── cryptocurrency │ └── crypto.js ├── package.json ├── handler └── index.js ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | package-lock.json 3 | config.json 4 | .github 5 | assets -------------------------------------------------------------------------------- /client/player.js: -------------------------------------------------------------------------------- 1 | const { Player } = require("discord-player"); 2 | const client = require("../index.js"); 3 | 4 | const player = new Player(client); 5 | 6 | module.exports = player; 7 | -------------------------------------------------------------------------------- /events/ready.js: -------------------------------------------------------------------------------- 1 | const client = require("../index"); 2 | const AsciiTable = require("ascii-table"); 3 | 4 | client.on("ready", () => { 5 | console.clear(); 6 | const table = new AsciiTable(); 7 | table.addRow(`${client.user.tag} has loaded! 🎈`); 8 | client.user.setActivity("the Bot Olympics", { type: "COMPETING" }); 9 | console.log(table.toString()); 10 | }); 11 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const { Client, Collection } = require("discord.js"); 2 | 3 | const client = new Client({ 4 | intents: 32767, 5 | }); 6 | module.exports = client; 7 | 8 | // Global Variables 9 | client.commands = new Collection(); 10 | client.slashCommands = new Collection(); 11 | client.config = require("./config.json"); 12 | 13 | // Initializing the project 14 | require("./handler")(client); 15 | 16 | process.on("unhandledRejection", (err) => { 17 | console.log("\nindex.js:9: Unhandled Rejection at: ", err); 18 | }); 19 | 20 | client.login(client.config.token); 21 | -------------------------------------------------------------------------------- /events/messageCreate.js: -------------------------------------------------------------------------------- 1 | const client = require("../index"); 2 | 3 | client.on("messageCreate", async (message) => { 4 | if (message.author.bot || !message.guild || !message.content.toLowerCase().startsWith(client.config.prefix)) return; 5 | 6 | const [cmd, ...args] = message.content 7 | .slice(client.config.prefix.length) 8 | .trim() 9 | .split(" "); 10 | 11 | const command = client.commands.get(cmd.toLowerCase()) || client.commands.find(c => c.aliases?.includes(cmd.toLowerCase())); 12 | 13 | if (!command) return; 14 | await command.run(client, message, args); 15 | }); 16 | -------------------------------------------------------------------------------- /commands/info/ping.js: -------------------------------------------------------------------------------- 1 | const { Message, Client, MessageEmbed } = require("discord.js"); 2 | 3 | module.exports = { 4 | name: "", 5 | aliases: [], 6 | /** 7 | * 8 | * @param {Client} client 9 | * @param {Message} message 10 | * @param {String[]} args 11 | */ 12 | run: async (client, message, args) => { 13 | const pingEmbed = new MessageEmbed() 14 | .setFields({ name: ":satellite: **Ping**", value: `\`\`\`${client.ws.ping} ms\`\`\`` }) 15 | .setColor("RANDOM") 16 | .setTimestamp() 17 | .setFooter(client.user.username, client.user.displayAvatarURL()); 18 | message.channel.send({ embeds: [pingEmbed] }); 19 | }, 20 | }; 21 | -------------------------------------------------------------------------------- /SlashCommands/fun/coinflip.js: -------------------------------------------------------------------------------- 1 | const { Client, CommandInteraction, MessageEmbed } = require("discord.js"); 2 | const { SlashCommandBuilder } = require("@discordjs/builders"); 3 | 4 | module.exports = { 5 | userPermissions: ["SEND_MESSAGES"], 6 | ...new SlashCommandBuilder() 7 | .setName("coinflip") 8 | .setDescription("Flip a coin"), 9 | 10 | run: async (client, interaction, args) => { 11 | 12 | const daCoin = ["HEADS!", "TAILS!"]; 13 | 14 | function headsOrTails(coin) { 15 | return coin[(Math.floor(Math.random() * coin.length))]; 16 | } 17 | interaction.followUp({ 18 | embeds: [new MessageEmbed() 19 | .setTitle(`You got **\`${headsOrTails(daCoin)}\`** :coin:`) 20 | .setTimestamp() 21 | .setFooter(client.user.username, client.user.displayAvatarURL())] 22 | }); 23 | 24 | }, 25 | }; 26 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Keplar", 3 | "version": "1.0.0", 4 | "description": "Multipurpose Bot", 5 | "main": "index.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/humaiyun/Keplar.git" 9 | }, 10 | "scripts": { 11 | "start": "node index.js", 12 | "test": "nodemon index.js" 13 | }, 14 | "keywords": [], 15 | "author": "Humaiyun", 16 | "license": "ISC", 17 | "homepage": "https://github.com/humaiyun/Keplar#readme", 18 | "dependencies": { 19 | "@discordjs/builders": "^0.6.0", 20 | "@discordjs/opus": "^0.6.0", 21 | "ascii-table": "^0.0.9", 22 | "cpu-stat": "^2.0.1", 23 | "discord-player": "^5.1.0", 24 | "discord.js": "^13.2.0-dev.1633133131.fe95005", 25 | "ffmpeg-static": "^4.4.0", 26 | "glob": "^7.1.7", 27 | "got": "^11.8.2", 28 | "mongoose": "^6.0.2", 29 | "nodemon": "^2.0.13", 30 | "relevant-urban": "^2.0.0" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SlashCommands/info/ping.js: -------------------------------------------------------------------------------- 1 | const { Client, CommandInteraction, MessageEmbed } = require("discord.js"); 2 | const { SlashCommandBuilder } = require("@discordjs/builders"); 3 | 4 | module.exports = { 5 | // name: "ping", 6 | // description: "Displays the ping of the bot", 7 | // type: 'CHAT_INPUT', 8 | userPermissions: ["SEND_MESSAGES"], 9 | ...new SlashCommandBuilder() 10 | .setName("ping") 11 | .setDescription("Displays the ping of the bot"), 12 | /** 13 | * 14 | * @param {Client} client 15 | * @param {CommandInteraction} interaction 16 | * @param {String[]} args 17 | */ 18 | run: async (client, interaction, args) => { 19 | const pingEmbed = new MessageEmbed() 20 | .setFields({ name: ":satellite: **Ping**", value: `\`\`\`${client.ws.ping} ms\`\`\`` }) 21 | .setColor("RANDOM") 22 | .setTimestamp() 23 | .setFooter(client.user.username, client.user.displayAvatarURL()); 24 | interaction.followUp({ embeds: [pingEmbed] }); 25 | }, 26 | }; 27 | -------------------------------------------------------------------------------- /SlashCommands/music/skip.js: -------------------------------------------------------------------------------- 1 | 2 | const { MessageEmbed } = require("discord.js"); 3 | const { SlashCommandBuilder } = require("@discordjs/builders"); 4 | const player = require("../../client/player"); 5 | 6 | module.exports = { 7 | userPermissions: ["SEND_MESSAGES"], 8 | ...new SlashCommandBuilder() 9 | .setName("skip") 10 | .setDescription(`Skips the current track`), 11 | 12 | run: async (client, interaction, args) => { 13 | const queue = player.getQueue(interaction.guildId); 14 | 15 | if (!queue?.playing) 16 | return interaction.followUp({ 17 | embeds: [new MessageEmbed() 18 | .setColor("RED") 19 | .setDescription(`❌ | No music is currently being played`)] 20 | }); 21 | 22 | await queue.skip(); 23 | 24 | console.log(`\nmusic/pause.js:25: ${interaction.user.tag} skipped the current track...`); 25 | 26 | return interaction.followUp({ 27 | embeds: [new MessageEmbed() 28 | .setColor("RANDOM") 29 | .setDescription(`✅ | Skipped the current track`)] 30 | }); 31 | } 32 | }; -------------------------------------------------------------------------------- /SlashCommands/music/pause.js: -------------------------------------------------------------------------------- 1 | 2 | const { MessageEmbed } = require("discord.js"); 3 | const { SlashCommandBuilder } = require("@discordjs/builders"); 4 | const player = require("../../client/player"); 5 | 6 | module.exports = { 7 | userPermissions: ["SEND_MESSAGES"], 8 | ...new SlashCommandBuilder() 9 | .setName("pause") 10 | .setDescription(`Pauses the current track`), 11 | 12 | run: async (client, interaction, args) => { 13 | const queue = player.getQueue(interaction.guildId); 14 | 15 | if (!queue?.playing) { 16 | return interaction.followUp({ 17 | embeds: [new MessageEmbed() 18 | .setColor("RED") 19 | .setDescription(`❌ | No music is currently being played`)] 20 | }); 21 | } 22 | 23 | queue.setPaused(true); 24 | 25 | console.log(`\nmusic/pause.js:25: ${interaction.user.tag} paused the current track...`); 26 | 27 | return interaction.followUp({ 28 | embeds: [new MessageEmbed() 29 | .setColor("RANDOM") 30 | .setDescription(`✅ | Paused the current track`)] 31 | }); 32 | } 33 | }; -------------------------------------------------------------------------------- /SlashCommands/music/resume.js: -------------------------------------------------------------------------------- 1 | 2 | const { MessageEmbed } = require("discord.js"); 3 | const { SlashCommandBuilder } = require("@discordjs/builders"); 4 | const player = require("../../client/player"); 5 | 6 | module.exports = { 7 | userPermissions: ["SEND_MESSAGES"], 8 | ...new SlashCommandBuilder() 9 | .setName("resume") 10 | .setDescription(`Resumes the current track`), 11 | 12 | run: async (client, interaction, args) => { 13 | const queue = player.getQueue(interaction.guildId); 14 | 15 | if (!queue?.playing) { 16 | return interaction.followUp({ 17 | embeds: [new MessageEmbed() 18 | .setColor("RED") 19 | .setDescription(`❌ | No music is currently being played`)] 20 | }); 21 | } 22 | 23 | queue.setPaused(false); 24 | 25 | console.log(`\nmusic/resume.js:25: ${interaction.user.tag} resumed the current track...`); 26 | 27 | return interaction.followUp({ 28 | embeds: [new MessageEmbed() 29 | .setColor("RANDOM") 30 | .setDescription(`✅ | Resumed the current track`)] 31 | }); 32 | } 33 | }; -------------------------------------------------------------------------------- /SlashCommands/music/shuffle.js: -------------------------------------------------------------------------------- 1 | 2 | const { MessageEmbed } = require("discord.js"); 3 | const { SlashCommandBuilder } = require("@discordjs/builders"); 4 | const player = require("../../client/player"); 5 | 6 | module.exports = { 7 | userPermissions: ["SEND_MESSAGES"], 8 | ...new SlashCommandBuilder() 9 | .setName("shuffle") 10 | .setDescription(`Shuffle the current queue`), 11 | 12 | run: async (client, interaction, args) => { 13 | 14 | const queue = player.getQueue(interaction.guildId); 15 | if (!queue?.playing) { 16 | return interaction.followUp({ 17 | embeds: [new MessageEmbed() 18 | .setColor("RED") 19 | .setDescription(`❌ | No music is currently being played`)] 20 | }); 21 | } 22 | 23 | await queue.shuffle(); 24 | 25 | console.log(`\nmusic/shuffle.js:25: ${interaction.user.tag} shuffled the queue...`); 26 | 27 | return interaction.followUp({ 28 | embeds: [new MessageEmbed() 29 | .setColor("RANDOM") 30 | .setDescription(`✅ | Queue has been shuffled`)] 31 | }); 32 | } 33 | 34 | }; -------------------------------------------------------------------------------- /SlashCommands/fun/advice.js: -------------------------------------------------------------------------------- 1 | const { Client, CommandInteraction, MessageEmbed } = require("discord.js"); 2 | const { SlashCommandBuilder } = require("@discordjs/builders"); 3 | const got = require("got"); 4 | 5 | module.exports = { 6 | userPermissions: ["SEND_MESSAGES"], 7 | ...new SlashCommandBuilder() 8 | .setName("advice") 9 | .setDescription("Generate a random piece of advice"), 10 | 11 | run: async (client, interaction, args) => { 12 | 13 | got('https://api.adviceslip.com/advice', { JSON: true }) 14 | .catch(err => { 15 | interaction.followUp({ 16 | embeds: [new MessageEmbed() 17 | .setColor("RED") 18 | .setDescription(`If you need help, type \`${config.prefix}help\`\n\n` + `\`${err}\``)] 19 | }); 20 | }) 21 | .then(result => { 22 | const content = JSON.parse(result.body); 23 | const advice = content.slip.advice; 24 | interaction.followUp({ 25 | embeds: [new MessageEmbed() 26 | .setColor("RANDOM") 27 | .setDescription(advice)] 28 | }); 29 | }); 30 | 31 | }, 32 | }; 33 | -------------------------------------------------------------------------------- /SlashCommands/images/cat.js: -------------------------------------------------------------------------------- 1 | const { Client, CommandInteraction, MessageEmbed } = require("discord.js"); 2 | const { SlashCommandBuilder } = require("@discordjs/builders"); 3 | const got = require("got"); 4 | 5 | module.exports = { 6 | userPermissions: ["SEND_MESSAGES"], 7 | ...new SlashCommandBuilder() 8 | .setName("cat") 9 | .setDescription("Generate a random image of a cat"), 10 | 11 | run: async (client, interaction, args) => { 12 | got("https://api.thecatapi.com/v1/images/search", { JSON: true }) 13 | .catch((err) => { 14 | interaction.followUp({ 15 | embeds: [new MessageEmbed() 16 | .setAuthor("Error") 17 | .setColor("RED") 18 | .setTimestamp() 19 | .setFooter(client.user.username, client.user.displayAvatarURL()) 20 | .setDescription(`Error Message: \`${err}\``)] 21 | }); 22 | }) 23 | .then(result => { 24 | const content = JSON.parse(result.body); 25 | const catImg = content[0].url; 26 | interaction.followUp({ 27 | embeds: [new MessageEmbed() 28 | .setColor("RANDOM") 29 | .setTitle(`\u200b:smiley_cat:`) 30 | .setImage(catImg) 31 | .setTimestamp() 32 | .setFooter(client.user.username, client.user.displayAvatarURL())] 33 | }); 34 | }) 35 | 36 | }, 37 | }; 38 | -------------------------------------------------------------------------------- /SlashCommands/music/seek.js: -------------------------------------------------------------------------------- 1 | 2 | const { MessageEmbed } = require("discord.js"); 3 | const { SlashCommandBuilder } = require("@discordjs/builders"); 4 | const player = require("../../client/player"); 5 | 6 | module.exports = { 7 | userPermissions: ["ADMINISTRATOR"], 8 | ...new SlashCommandBuilder() 9 | .setName("seek") 10 | .setDescription(`Seek to the given time for the current track`) 11 | .addIntegerOption((option) => 12 | option 13 | .setName("time") 14 | .setDescription("The time to seek to (in seconds)") 15 | .setRequired(true) 16 | ), 17 | 18 | run: async (client, interaction, args) => { 19 | const queue = player.getQueue(interaction.guildId); 20 | 21 | if (!queue?.playing) { 22 | return interaction.followUp({ 23 | embeds: [new MessageEmbed() 24 | .setColor("RED") 25 | .setDescription(`❌ | No music is currently being played`)] 26 | }); 27 | } 28 | 29 | let time = interaction.options.getInteger("time") * 1000; 30 | 31 | if (time < 0) time = 0; 32 | if (time > queue.current.durationMS) time = queue.current.durationMS - 1; 33 | 34 | console.log(`music/seek.js:34: time: ${time}`) 35 | await queue.seek(time); 36 | 37 | console.log(`music/seek.js:37: ${interaction.user.tag} seeked to ${time / 1000} seconds for the current track...`); 38 | 39 | return interaction.followUp({ 40 | embeds: [new MessageEmbed() 41 | .setColor("RED") 42 | .setDescription(`✅ | Seeked to ${time / 1000} seconds`)] 43 | }); 44 | 45 | } 46 | }; -------------------------------------------------------------------------------- /SlashCommands/music/currentSong.js: -------------------------------------------------------------------------------- 1 | 2 | const { MessageEmbed } = require("discord.js"); 3 | const { SlashCommandBuilder } = require("@discordjs/builders"); 4 | const player = require("../../client/player"); 5 | 6 | module.exports = { 7 | userPermissions: ["SEND_MESSAGES"], 8 | ...new SlashCommandBuilder() 9 | .setName("current-song") 10 | .setDescription(`Shows information about the current song`), 11 | 12 | run: async (client, interaction, args) => { 13 | const queue = player.getQueue(interaction.guildId); 14 | 15 | if (!queue?.playing) 16 | return interaction.followUp({ 17 | embeds: [new MessageEmbed() 18 | .setColor("RED") 19 | .setDescription(`❌ | No music is currently being played`)] 20 | }); 21 | 22 | const progress = queue.createProgressBar(); 23 | 24 | return interaction.followUp({ 25 | embeds: [new MessageEmbed() 26 | .setTitle(`🎶 ${queue.current.title} 🎶`) 27 | .setImage(`${queue.current.thumbnail}`) 28 | .setURL(`${queue.current.url}`) 29 | .setColor("RANDOM") // client.config.clientColor 30 | .setDescription(`\n\u200b\n🖥 **Uploaded By: ** ${queue.current.author}\n\u200b\n👀 **Views: ** ${queue.current.views.toLocaleString("en-US")}`) // (\`${percent.progress}%\`) // 31 | .setFields({ 32 | name: "\u200b", 33 | value: `${progress}`, 34 | inline: false 35 | }) 36 | .setFooter(`Queued by ${queue.current.requestedBy.tag}`, queue.current.requestedBy.displayAvatarURL()) 37 | .setTimestamp() 38 | ], 39 | }); 40 | 41 | } 42 | }; -------------------------------------------------------------------------------- /SlashCommands/music/queue.js: -------------------------------------------------------------------------------- 1 | 2 | const { MessageEmbed } = require("discord.js"); 3 | const { SlashCommandBuilder } = require("@discordjs/builders"); 4 | const player = require("../../client/player"); 5 | 6 | module.exports = { 7 | userPermissions: ["SEND_MESSAGES"], 8 | ...new SlashCommandBuilder() 9 | .setName("queue") 10 | .setDescription(`Shows the queue`), 11 | 12 | run: async (client, interaction, args) => { 13 | const queue = player.getQueue(interaction.guildId); 14 | if (!queue?.playing) 15 | return interaction.followUp({ 16 | embeds: [new MessageEmbed() 17 | .setColor("RED") 18 | .setDescription(`❌ | The queue is empty!`)] 19 | }); 20 | 21 | const currentTrack = queue.current; 22 | const tracks = queue.tracks.slice(0, 10).map((m, i) => { 23 | return `${i + 1}. [**${m.title}**](${m.url}) - ${m.requestedBy.tag}`; 24 | }); 25 | 26 | return interaction.followUp({ 27 | embeds: [new MessageEmbed() 28 | .setColor("RANDOM") 29 | .setTitle("📃 Queue") 30 | .setDescription(`${tracks.join("\n")}${queue.tracks.length > tracks.length 31 | ? `\n...${queue.tracks.length - tracks.length === 1 32 | ? `${queue.tracks.length - tracks.length 33 | } more track` 34 | : `${queue.tracks.length - tracks.length 35 | } more tracks` 36 | }` 37 | : "" 38 | }`) 39 | .setFields({ 40 | name: `Now Playing`, 41 | value: `🎶 | [**${currentTrack.title}**](${currentTrack.url}) - \`${currentTrack.requestedBy.tag}\``, 42 | inline: false 43 | }) 44 | ] 45 | }); 46 | 47 | } 48 | }; -------------------------------------------------------------------------------- /SlashCommands/music/volume.js: -------------------------------------------------------------------------------- 1 | 2 | const { MessageEmbed } = require("discord.js"); 3 | const { SlashCommandBuilder } = require("@discordjs/builders"); 4 | const player = require("../../client/player"); 5 | 6 | module.exports = { 7 | userPermissions: ["SEND_MESSAGES"], 8 | ...new SlashCommandBuilder() 9 | .setName("volume") 10 | .setDescription(`Adjusts the volume of the bot`) 11 | .addIntegerOption((option) => 12 | option 13 | .setName("percentage") 14 | .setDescription("Enter the percentage you want to change the volume to") 15 | .setRequired(false) 16 | ), 17 | run: async (client, interaction, args) => { 18 | const volumePercentage = interaction.options.getInteger("percentage"); 19 | const queue = player.getQueue(interaction.guildId); 20 | if (!queue?.playing) 21 | return interaction.followUp({ 22 | embeds: [new MessageEmbed() 23 | .setColor("RED") 24 | .setDescription(`❌ | No music is currently being played`)] 25 | }); 26 | 27 | if (!volumePercentage) { 28 | return interaction.followUp({ 29 | embeds: [new MessageEmbed() 30 | .setColor("RANDOM") 31 | .setDescription(`The current volume is \`${queue.volume}%\``)] 32 | }); 33 | } 34 | 35 | if (volumePercentage < 0 || volumePercentage > 100) 36 | return interaction.followUp({ 37 | embeds: [new MessageEmbed() 38 | .setColor("RED") 39 | .setDescription(`❌ | The volume must be between 1 and 100`)] 40 | }); 41 | 42 | queue.setVolume(volumePercentage); 43 | 44 | return interaction.followUp({ 45 | embeds: [new MessageEmbed() 46 | .setColor("RANDOM") 47 | .setDescription(`✅ | Volume has been set to \`${volumePercentage}%\``)] 48 | }); 49 | 50 | } 51 | }; -------------------------------------------------------------------------------- /events/interactionCreate.js: -------------------------------------------------------------------------------- 1 | const client = require("../index"); 2 | const { MessageEmbed } = require("discord.js"); 3 | 4 | client.on("interactionCreate", async (interaction) => { 5 | // Slash Command Handling 6 | if (interaction.isCommand()) { 7 | await interaction.deferReply({ ephemeral: false }).catch(() => { }); 8 | 9 | const cmd = client.slashCommands.get(interaction.commandName); 10 | if (!cmd) { 11 | return interaction.followUp({ 12 | embeds: [new MessageEmbed() 13 | .setColor("RED") 14 | .setDescription(`interactionCreate.js:13: An error has occurred`)] 15 | }); 16 | } 17 | 18 | await interaction.deferReply({ ephemeral: cmd.ephemeral ? cmd.ephemeral : false }).catch(() => { }); 19 | 20 | const args = []; 21 | 22 | for (let option of interaction.options.data) { 23 | if (option.type === "SUB_COMMAND") { 24 | if (option.name) args.push(option.name); 25 | option.options?.forEach((x) => { 26 | if (x.value) args.push(x.value); 27 | }); 28 | } else if (option.value) args.push(option.value); 29 | } 30 | interaction.member = interaction.guild.members.cache.get(interaction.user.id); 31 | 32 | if (!interaction.member.permissions.has(cmd.userPermissions || [])) 33 | return interaction.followUp({ 34 | embeds: [new MessageEmbed() 35 | .setColor("RED") 36 | .setDescription(`You do not have permissions to use this command`)] 37 | }); 38 | 39 | cmd.run(client, interaction, args); 40 | } 41 | 42 | // Context Menu Handling 43 | if (interaction.isContextMenu()) { 44 | await interaction.deferReply({ ephemeral: command.ephemeral ? command.ephemeral : false }); 45 | const command = client.slashCommands.get(interaction.commandName); 46 | if (command) command.run(client, interaction); 47 | } 48 | }); 49 | -------------------------------------------------------------------------------- /SlashCommands/fun/8ball.js: -------------------------------------------------------------------------------- 1 | const { Client, CommandInteraction, MessageEmbed } = require("discord.js"); 2 | const { SlashCommandBuilder } = require("@discordjs/builders"); 3 | 4 | module.exports = { 5 | userPermissions: ["SEND_MESSAGES"], 6 | ...new SlashCommandBuilder() 7 | .setName("8ball") 8 | .setDescription("Receive a fortune from the Magic 8-Ball") 9 | .addStringOption((option) => 10 | option 11 | .setName("question") 12 | .setDescription("Enter a question that you want a fortune for") 13 | .setRequired(true) 14 | ), 15 | 16 | run: async (client, interaction, args) => { 17 | 18 | const fortunes = 19 | [ 20 | "It is certain.", "It is decidedly so.", "Without a doubt.", "Yes definitely.", "You may rely on it.", 21 | "As I see it, yes.", "Most likely.", "Outlook good.", "Yes.", "Signs point to yes.", 22 | "Reply hazy, try again.", "Ask again later.", "Better not tell you now.", "Cannot predict now.", "Concentrate and ask again.", 23 | "Don't count on it.", "My reply is no.", "My sources say no.", "Outlook not so good", "Very doubtful." 24 | ]; 25 | 26 | const str = interaction.options.getString("question"); 27 | 28 | return interaction.followUp({ 29 | embeds: [new MessageEmbed() 30 | .setTitle("🎱 Magic 8-Ball") 31 | .setColor("RANDOM") 32 | .setTimestamp() 33 | .setFooter(client.user.username, client.user.displayAvatarURL()) 34 | .addFields({ 35 | name: "Question", 36 | value: `\`\`\`${str}\`\`\``, 37 | inline: false 38 | }, { 39 | name: "Answer", 40 | value: `\`\`\`${fortunes[Math.floor(Math.random() * fortunes.length)]}\`\`\``, 41 | inline: false 42 | })] 43 | //.setFooter(interaction.member.displayName, interaction.author.displayAvatarURL({ dynamic: true }))] 44 | }); 45 | 46 | }, 47 | }; 48 | -------------------------------------------------------------------------------- /SlashCommands/utility/clear.js: -------------------------------------------------------------------------------- 1 | const { Client, CommandInteraction, MessageEmbed } = require("discord.js"); 2 | const { SlashCommandBuilder } = require("@discordjs/builders"); 3 | 4 | module.exports = { 5 | userPermissions: ["ADMINISTRATOR"], 6 | ...new SlashCommandBuilder() 7 | .setName("clear") 8 | .setDescription("Clears a specified amount of messages") 9 | .addIntegerOption((option) => 10 | option 11 | .setName("amount") 12 | .setDescription("Number of messages you want to clear") 13 | .setRequired(true) 14 | ), 15 | 16 | run: async (client, interaction, args) => { 17 | 18 | const amount = interaction.options.getInteger("amount"); 19 | const user = interaction.user.tag; 20 | //console.log(`amount: ${amount} user: ${user}`); 21 | 22 | if (amount > 75) { 23 | return interaction.followUp({ 24 | embeds: [new MessageEmbed() 25 | .setColor("RED") 26 | .setTimestamp() 27 | .setFooter(client.user.username, client.user.displayAvatarURL()) 28 | .setDescription(`You cannot clear more than \`75\` messages!`)] 29 | }); 30 | } 31 | else if (amount < 0) { 32 | return interaction.followUp({ 33 | embeds: [new MessageEmbed() 34 | .setColor("RED") 35 | .setTimestamp() 36 | .setFooter(client.user.username, client.user.displayAvatarURL()) 37 | .setDescription(`You must clear at least \`1\` message!`)] 38 | }); 39 | } 40 | 41 | 42 | interaction.channel.bulkDelete(amount + 1); 43 | console.log(`\nutility/clear.js:48: ${user} cleared ${amount} messages...`); 44 | 45 | const msg = await interaction.channel.send({ 46 | embeds: [new MessageEmbed() 47 | .setColor("RANDOM") 48 | .setDescription(`Cleared \`${amount}\` messages!`)] 49 | }); 50 | 51 | setTimeout(() => { msg.delete() }, 2500); 52 | 53 | }, 54 | }; 55 | -------------------------------------------------------------------------------- /SlashCommands/info/stats.js: -------------------------------------------------------------------------------- 1 | const { Client, CommandInteraction, MessageEmbed } = require("discord.js"); 2 | const { SlashCommandBuilder } = require("@discordjs/builders"); 3 | 4 | module.exports = { 5 | userPermissions: ["SEND_MESSAGES"], 6 | ...new SlashCommandBuilder() 7 | .setName("stats") 8 | .setDescription("Displays statistics of the bot"), 9 | 10 | run: async (client, interaction, args) => { 11 | let totalSeconds = interaction.client.uptime / 1000; 12 | const days = Math.floor(totalSeconds / 86400); 13 | totalSeconds %= 86400; 14 | const hours = Math.floor(totalSeconds / 3600); 15 | totalSeconds %= 3600; 16 | const minutes = Math.floor(totalSeconds / 60); 17 | const seconds = Math.floor(totalSeconds % 60); 18 | 19 | const uptime = `\`\`\`${days} days, ${hours} hours, ${minutes} minutes and ${seconds} seconds\`\`\``; 20 | 21 | const embed = new MessageEmbed() 22 | .setTitle(`${interaction.client.user.username} Stats`) 23 | .addFields({ 24 | name: "Servers", 25 | value: `\`\`\`${client.guilds.cache.size}\`\`\``, 26 | inline: true 27 | }, { 28 | name: "Users", 29 | value: `\`\`\`${client.users.cache.size}\`\`\``, 30 | inline: true 31 | }, { 32 | name: "Channels", 33 | value: `\`\`\`${client.channels.cache.size}\`\`\``, 34 | inline: true 35 | }, { 36 | name: "Uptime", 37 | value: uptime, 38 | inline: true 39 | }, { 40 | name: "Ping", 41 | value: `\`\`\`${Math.round(interaction.client.ws.ping)} ms\`\`\``, 42 | inline: true 43 | }, { 44 | name: "RAM", 45 | value: `\`\`\`${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB\`\`\``, 46 | inline: true 47 | }) 48 | .setColor("RANDOM") 49 | .setTimestamp() 50 | .setFooter(client.user.username, client.user.displayAvatarURL()); 51 | 52 | interaction.followUp({ embeds: [embed] }) 53 | }, 54 | }; 55 | -------------------------------------------------------------------------------- /SlashCommands/music/play.js: -------------------------------------------------------------------------------- 1 | /* https://github.com/Androz2091/discord-player/issues/794#issue-1000772967 */ 2 | const { MessageEmbed } = require("discord.js"); 3 | const { SlashCommandBuilder } = require("@discordjs/builders"); 4 | const { QueryType } = require("discord-player"); 5 | const player = require("../../client/player"); 6 | 7 | module.exports = { 8 | userPermissions: ["SEND_MESSAGES"], 9 | ...new SlashCommandBuilder() 10 | .setName("play") 11 | .setDescription(`Play a song`) 12 | .addStringOption((option) => 13 | option 14 | .setName("song") 15 | .setDescription("Enter the name or YouTube link of the song you want to play") 16 | .setRequired(true) 17 | ), 18 | run: async (client, interaction, args) => { 19 | const songTitle = interaction.options.getString("song"); 20 | 21 | // Check if user is in voice channel 22 | if (!interaction.member.voice.channel) 23 | return interaction.followUp({ 24 | embeds: [new MessageEmbed() 25 | .setColor("RED") 26 | .setDescription(`❌ | You must be in a voice channel to use this command!`)] 27 | }); 28 | 29 | // Search the song query 30 | const searchResult = await player.search(songTitle, { 31 | requestedBy: interaction.user, 32 | searchEngine: QueryType.AUTO, 33 | }); 34 | 35 | // Create a queue 36 | const queue = await player.createQueue(interaction.guild, { 37 | metadata: interaction.channel, 38 | }); 39 | 40 | // Connect to voice channel that the requested user is in 41 | if (!queue.connection) { 42 | await queue.connect(interaction.member.voice.channel); 43 | } 44 | 45 | interaction.followUp({ 46 | embeds: [new MessageEmbed() 47 | .setColor("RANDOM") 48 | .setDescription(`✅ | Added "\`${songTitle}\`" to the queue`)] 49 | }); 50 | console.log(`\nmusic/play.js:50: ${interaction.user.tag} added ${songTitle} to the queue...`); 51 | 52 | // Add tracks to queue 53 | searchResult.playlist 54 | ? queue.addTracks(searchResult.tracks) 55 | : queue.addTrack(searchResult.tracks[0]); 56 | 57 | if (!queue.playing) await queue.play(); 58 | 59 | } 60 | 61 | 62 | }; -------------------------------------------------------------------------------- /SlashCommands/misc/ud.js: -------------------------------------------------------------------------------- 1 | const { Client, CommandInteraction, MessageEmbed } = require("discord.js"); 2 | const { SlashCommandBuilder } = require("@discordjs/builders"); 3 | const urban = require('relevant-urban'); 4 | const got = require("got"); 5 | 6 | module.exports = { 7 | userPermissions: ["SEND_MESSAGES"], 8 | ...new SlashCommandBuilder() 9 | .setName("ud") 10 | .setDescription("Get the top Urban Dictionary definition of a word or sentence") 11 | .addStringOption((option) => 12 | option 13 | .setName("word") 14 | .setDescription("Enter a word or sentence to get the definition of") 15 | .setRequired(true) 16 | ), 17 | 18 | run: async (client, interaction, args) => { 19 | 20 | const word = interaction.options.getString("word"); 21 | 22 | const definition = await urban(word).catch(err => { 23 | interaction.followUp({ 24 | embeds: [new MessageEmbed() 25 | //.setAuthor("Error") 26 | .setColor("RED") 27 | .setTimestamp() 28 | .setFooter(client.user.username, client.user.displayAvatarURL()) 29 | .setDescription(`A definition for "${word}" could not be found. \n\nIf you need help, type \`${config.prefix}help\`\n\n` + `Error Message: \`${err}\``)] 30 | }); 31 | }) 32 | const defEmbed = new MessageEmbed() 33 | .setColor("RANDOM") 34 | .setTitle(`${definition.word}`) 35 | .setURL(definition.urbanURL) 36 | .addFields({ 37 | name: ":notebook_with_decorative_cover: Definition", 38 | value: `\`${definition.definition}\`\n` ? `\`${definition.definition}\`\n` : "\`No description found...\`", 39 | inline: false 40 | }, { 41 | name: ":bookmark: Example", 42 | value: `\`${definition.example}\`\n` ? `\`${definition.example}\`\n` : "\`No example found...\`", 43 | inline: false 44 | }, { 45 | name: ":writing_hand: Author", 46 | value: `\`${definition.author}\`\n` ? `\`${definition.author}\`\n` : "\`No author found...\`", 47 | inline: true 48 | }, { 49 | name: "Rating", 50 | value: `:thumbsup: \`${definition.thumbsUp}\` | :thumbsdown: \`${definition.thumbsDown}\` \n`, 51 | inline: true 52 | }) 53 | .setTimestamp() 54 | .setFooter(client.user.username, client.user.displayAvatarURL()); 55 | 56 | interaction.followUp({ embeds: [defEmbed] }); 57 | 58 | }, 59 | }; 60 | -------------------------------------------------------------------------------- /SlashCommands/utility/rng.js: -------------------------------------------------------------------------------- 1 | const { Client, CommandInteraction, MessageEmbed } = require("discord.js"); 2 | const { SlashCommandBuilder } = require("@discordjs/builders"); 3 | 4 | module.exports = { 5 | userPermissions: ["SEND_MESSAGES"], 6 | ...new SlashCommandBuilder() 7 | .setName("rng") 8 | .setDescription("Get a random number between two numbers") 9 | .addIntegerOption((option) => 10 | option 11 | .setName("minimum") 12 | .setDescription("The lower bound; smallest number") 13 | .setRequired(true) 14 | ) 15 | .addIntegerOption((option) => 16 | option 17 | .setName("maximum") 18 | .setDescription("The upper bound; biggest number") 19 | .setRequired(true) 20 | ), 21 | 22 | run: async (client, interaction, args) => { 23 | 24 | const lowest = interaction.options.getInteger("minimum"); 25 | const maximum = interaction.options.getInteger("maximum"); 26 | 27 | /** 28 | * Returns a random number between the min and max values (always assumes correct input) 29 | * @param {Integer} min - minimum index number 30 | * @param {Integer} max - maximum index number 31 | * @returns random number 32 | */ 33 | function randomNumMinToMax(min, max) { 34 | return Math.floor(Math.random() * (max - min + 1) + min); 35 | } 36 | 37 | if (lowest > maximum) { 38 | // return interaction.followUp({ 39 | // embeds: [new MessageEmbed() 40 | // .setColor("RED") 41 | // .setTimestamp() 42 | // .setFooter(client.user.username, client.user.displayAvatarURL()) 43 | // .setDescription(`The minimum number cannot be larger than the maximum number!\n\nYou entered: Min: \`${lowest}\`, Max: \`${maximum}\``)] 44 | // }); 45 | return interaction.followUp({ 46 | embeds: [new MessageEmbed() 47 | .setColor("RANDOM") 48 | .setTimestamp() 49 | .setFooter(client.user.username, client.user.displayAvatarURL()) 50 | .setDescription(`Random number between \`${lowest}\` and \`${maximum}\`: \`${randomNumMinToMax(maximum, lowest)}\``)] 51 | }); 52 | } 53 | else { 54 | return interaction.followUp({ 55 | embeds: [new MessageEmbed() 56 | .setColor("RANDOM") 57 | .setTimestamp() 58 | .setFooter(client.user.username, client.user.displayAvatarURL()) 59 | .setDescription(`Random number between \`${lowest}\` and \`${maximum}\` \n\`\`\`${randomNumMinToMax(lowest, maximum)}\`\`\``)] 60 | }); 61 | } 62 | 63 | }, 64 | }; 65 | -------------------------------------------------------------------------------- /SlashCommands/images/meme.js: -------------------------------------------------------------------------------- 1 | const { Client, CommandInteraction, MessageEmbed } = require("discord.js"); 2 | const { SlashCommandBuilder } = require("@discordjs/builders"); 3 | const got = require("got"); 4 | 5 | module.exports = { 6 | userPermissions: ["SEND_MESSAGES"], 7 | ...new SlashCommandBuilder() 8 | .setName("meme") 9 | .setDescription("Generate a random meme from Reddit"), 10 | 11 | run: async (client, interaction, args) => { 12 | const subreddit = ["memes", "dankmemes", "meirl", "me_irl", 13 | "greentext", "wholesomememes", "2meirl4meirl", "comedyheaven"]; 14 | const randomSub = subreddit[Math.floor(Math.random() * subreddit.length)]; 15 | 16 | // Connect to the API and then fetch the data 17 | got(`https://www.reddit.com/r/${randomSub}/random/.json`, { JSON: true }) 18 | .catch(err => { 19 | interaction.followUp({ 20 | embeds: [MessageEmbed() 21 | .setAuthor("Error") 22 | .setColor("RED") 23 | .setDescription(`Something wrong happened... \n\nIf you need help, type \`${config.prefix}help\`\n\n` + `Error Message: \`${err}\``)] 24 | }); 25 | }) 26 | .then(result => { 27 | const content = JSON.parse(result.body); 28 | 29 | const redditURL = content[0].data.children[0].data.url; 30 | const redditTitle = content[0].data.children[0].data.title; 31 | const subreddit = content[0].data.children[0].data.subreddit; 32 | const permalink = content[0].data.children[0].data.permalink; 33 | const author = content[0].data.children[0].data.author; 34 | const upvotes = `👍 ${content[0].data.children[0].data.ups} `; 35 | const downvotes = ` | 👎 ${content[0].data.children[0].data.downs} `; 36 | const comments = ` | 💬 ${content[0].data.children[0].data.num_comments} `; 37 | 38 | interaction.followUp({ 39 | embeds: [new MessageEmbed() 40 | .setColor("RANDOM") 41 | .setTitle(redditTitle) 42 | .setImage(redditURL) 43 | .setURL(`https://www.reddit.com${permalink}`) 44 | .addFields({ 45 | name: ":snowman: Subreddit", 46 | value: `${subreddit}`, 47 | inline: true 48 | }, { 49 | name: ":japanese_goblin: User", 50 | value: `${author}`, 51 | inline: true 52 | }) 53 | .setTimestamp() 54 | .setFooter(upvotes + downvotes + comments)] 55 | }); 56 | }); 57 | }, 58 | }; 59 | -------------------------------------------------------------------------------- /handler/index.js: -------------------------------------------------------------------------------- 1 | const { glob } = require("glob"); 2 | const { promisify } = require("util"); 3 | const { Client } = require("discord.js"); 4 | const mongoose = require("mongoose"); 5 | const config = require("../config.json"); 6 | 7 | const globPromise = promisify(glob); 8 | 9 | /** 10 | * @param {Client} client 11 | */ 12 | module.exports = async (client) => { 13 | // Commands 14 | const commandFiles = await globPromise(`${process.cwd()}/commands/**/*.js`); 15 | commandFiles.map((value) => { 16 | const file = require(value); 17 | const splitted = value.split("/"); 18 | const directory = splitted[splitted.length - 2]; 19 | 20 | if (file.name) { 21 | const properties = { directory, ...file }; 22 | client.commands.set(file.name, properties); 23 | } 24 | }); 25 | 26 | // Events 27 | const eventFiles = await globPromise(`${process.cwd()}/events/*.js`); 28 | eventFiles.map((value) => require(value)); 29 | 30 | // Slash Commands 31 | const slashCommands = await globPromise( 32 | `${process.cwd()}/SlashCommands/*/*.js` 33 | ); 34 | 35 | const arrayOfSlashCommands = []; 36 | slashCommands.map((value) => { 37 | const file = require(value); 38 | if (!file?.name) return; 39 | 40 | client.slashCommands.set(file.name, file); 41 | 42 | if (["MESSAGE", "USER"].includes(file.type)) delete file.description; 43 | if (file.userPermissions) file.defaultPermission = false; 44 | arrayOfSlashCommands.push(file); 45 | }); 46 | client.on("ready", async () => { 47 | // Register for a single guild 48 | const guild = client.guilds.cache.get(config.singleGuildId); 49 | await guild.commands.set(arrayOfSlashCommands).then((cmd) => { 50 | const getRoles = (commandName) => { 51 | const permissions = arrayOfSlashCommands 52 | .find(x => x.name === commandName).userPermissions; 53 | 54 | if (!permissions) return null; 55 | return guild.roles.cache.filter(x => x.permissions.has(permissions) && !x.managed); 56 | }; 57 | 58 | const fullPermissions = cmd.reduce((accumulator, x) => { 59 | const roles = getRoles(x.name); 60 | if (!roles) return accumulator; 61 | 62 | const permissions = roles.reduce((a, v) => { 63 | return [...a, { 64 | id: v.id, 65 | type: "ROLE", 66 | permission: true 67 | }] 68 | }, []) 69 | 70 | return [ 71 | ...accumulator, 72 | { 73 | id: x.id, 74 | permissions, 75 | } 76 | ] 77 | 78 | }, []) 79 | 80 | guild.commands.permissions.set({ fullPermissions }); 81 | 82 | }); 83 | 84 | // Register for all the guilds the bot is in 85 | // await client.application.commands.set(arrayOfSlashCommands); 86 | }); 87 | 88 | // mongodb 89 | // const { mongooseConnectionString } = require('../config.json') 90 | // if (!mongooseConnectionString) return; 91 | 92 | // mongoose.connect(mongooseConnectionString).then(() => console.log('Connected to mongodb')); 93 | }; 94 | -------------------------------------------------------------------------------- /SlashCommands/music/lyrics.js: -------------------------------------------------------------------------------- 1 | 2 | const { MessageEmbed } = require("discord.js"); 3 | const { SlashCommandBuilder } = require("@discordjs/builders"); 4 | const player = require("../../client/player"); 5 | const got = require("got"); 6 | 7 | module.exports = { 8 | userPermissions: ["SEND_MESSAGES"], 9 | ...new SlashCommandBuilder() 10 | .setName("lyrics") 11 | .setDescription(`Get the lyrics for a specific song`) 12 | .addStringOption((option) => 13 | option 14 | .setName("title") 15 | .setDescription("Enter the title of the song you want lyrics for") 16 | .setRequired(true) 17 | ), 18 | 19 | run: async (client, interaction, args) => { 20 | let song = interaction.options.getString('title'); 21 | song = song.replace(" ", "%20"); 22 | if (!song) { 23 | return interaction.followUp({ 24 | embeds: [new MessageEmbed() 25 | .setColor("RED") 26 | .setDescription(`❌ | Please provide a song to search for!`)] 27 | }) 28 | } 29 | 30 | got(`https://some-random-api.ml/lyrics?title=${song}`, { JSON: true }) 31 | .catch((err) => { 32 | interaction.followUp({ 33 | embeds: [new MessageEmbed() 34 | .setAuthor("Error") 35 | .setColor("RED") 36 | .setTimestamp() 37 | .setFooter(client.user.username, client.user.displayAvatarURL()) 38 | .setDescription(`Error Message: \`${err}\``)] 39 | }); 40 | }) 41 | .then(result => { 42 | const content = JSON.parse(result.body); 43 | 44 | const author = content.author; 45 | const title = content.title; 46 | const lyrics = content.lyrics; 47 | const thumbnail = content.thumbnail.genius; 48 | const link = content.links.genius; 49 | 50 | console.log(`\nlyrics.js:50: \`${author} - ${title}\` lyrics length: ${content.lyrics.length}`); 51 | 52 | if (lyrics.length > 4096) { 53 | return interaction.followUp({ 54 | embeds: [new MessageEmbed() 55 | .setColor("RANDOM") 56 | .setTitle(`${author} - ${title}`) 57 | .setImage(thumbnail) 58 | .setURL(link) 59 | .setDescription(`Lyrics are too long to show.`) 60 | .setTimestamp() 61 | .setFooter(client.user.username, client.user.displayAvatarURL())] 62 | }); 63 | } 64 | 65 | interaction.followUp({ 66 | embeds: [new MessageEmbed() 67 | .setColor("RANDOM") 68 | .setTitle(`${author} - ${title}`) 69 | .setImage(thumbnail) 70 | .setURL(link) 71 | .setDescription(`📄 **Lyrics**\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n${lyrics}`) 72 | .setTimestamp() 73 | .setFooter(client.user.username, client.user.displayAvatarURL())] 74 | }); 75 | }) 76 | 77 | } 78 | }; 79 | -------------------------------------------------------------------------------- /SlashCommands/misc/define.js: -------------------------------------------------------------------------------- 1 | const { Client, CommandInteraction, MessageEmbed } = require("discord.js"); 2 | const { SlashCommandBuilder } = require("@discordjs/builders"); 3 | const got = require("got"); 4 | 5 | module.exports = { 6 | userPermissions: ["SEND_MESSAGES"], 7 | ...new SlashCommandBuilder() 8 | .setName("define") 9 | .setDescription("Get the dictionary definition of a word") 10 | .addStringOption((option) => 11 | option 12 | .setName("word") 13 | .setDescription("Enter a word to get the definition of") 14 | .setRequired(true) 15 | ), 16 | 17 | run: async (client, interaction, args) => { 18 | 19 | const str = interaction.options.getString("word"); 20 | 21 | if (!isNaN(parseInt(str))) { // is a number 22 | return interaction.followUp({ 23 | embeds: [new MessageEmbed() 24 | .setColor("RANDOM") 25 | .setTitle("No Definitions Found") 26 | .setTimestamp() 27 | .setFooter(client.user.username, client.user.displayAvatarURL()) 28 | .setDescription(`No definitions have been found for the word you were looking for. \n\nTry the search again or head to the web instead.`)] 29 | }); 30 | } 31 | else { 32 | got(`https://api.dictionaryapi.dev/api/v2/entries/en/${str}`, { JSON: true }) 33 | .catch((err) => { 34 | return interaction.followUp({ 35 | embeds: [new MessageEmbed() 36 | .setAuthor("Error") 37 | .setColor("RED") 38 | .setTimestamp() 39 | .setFooter(client.user.username, client.user.displayAvatarURL()) 40 | .setDescription(`Error Message: \`${err}\``)] 41 | }); 42 | }) 43 | .then(result => { 44 | const content = JSON.parse(result.body); 45 | 46 | const wordWord = content[0].word; //.charAt(0).toUpperCase() + wordWord.slice(1) 47 | const wordOrigin = content[0].origin; 48 | const wordPartOfSpeech = content[0].meanings[0].partOfSpeech; 49 | const wordDefinition = content[0].meanings[0].definitions[0].definition; 50 | const wordPhonetic = content[0].phonetic; 51 | const wordExample = content[0].meanings[0].definitions[0].example; 52 | 53 | return interaction.followUp({ 54 | embeds: [new MessageEmbed() 55 | .setColor("RANDOM") 56 | .setTitle(wordWord) 57 | .setTimestamp() 58 | .setFooter(client.user.username, client.user.displayAvatarURL()) 59 | .setDescription(`**Definition**\n\`${wordDefinition}\`\n\n**Orirgin**\n\`${wordOrigin === undefined ? "None given" : wordOrigin}\`\n\n**Example**\n\`${wordExample === undefined ? "None given" : wordExample}\``) 60 | .setURL(`https://www.google.com/search?q=${str}%20definition`) 61 | .addFields({ 62 | name: `Part of Speech`, 63 | value: `\`${wordPartOfSpeech === undefined ? "None given" : wordPartOfSpeech}\``, 64 | inline: true 65 | }, { 66 | name: `Phonetic`, 67 | value: `\`${wordPhonetic === undefined ? "None given" : wordPhonetic}\``, 68 | inline: true 69 | })] 70 | }); 71 | }); 72 | } 73 | 74 | 75 | 76 | 77 | }, 78 | }; 79 | -------------------------------------------------------------------------------- /SlashCommands/info/info.js: -------------------------------------------------------------------------------- 1 | const { Client, CommandInteraction, MessageEmbed } = require("discord.js"); 2 | const { SlashCommandBuilder } = require("@discordjs/builders"); 3 | const Discord = require("discord.js"); 4 | const os = require("os"); 5 | const cpuStat = require("cpu-stat"); 6 | 7 | module.exports = { 8 | userPermissions: ["SEND_MESSAGES"], 9 | ...new SlashCommandBuilder() 10 | .setName("info") 11 | .setDescription("Shows a detailed list of bot and server information"), 12 | 13 | run: async (client, interaction, args) => { 14 | 15 | cpuStat.usagePercent(function (err, percent, seconds) { 16 | if (err) return console.log(`info.js:16: Error: ${err}`); 17 | 18 | let conAmt = 0; 19 | let guilds = client.guilds.cache.map((guild) => guild); 20 | for (let i = 0; i < guilds.length; i++) { 21 | if (guilds[i].me.voice.channel) conAmt += 1; 22 | } 23 | if (conAmt > client.guilds.cache.size) conAmt = client.guilds.cache.size; 24 | 25 | interaction.followUp({ 26 | embeds: [new MessageEmbed() 27 | //.setAuthor(client.user.username, client.user.displayAvatarURL()) 28 | .setTitle("__Bot & Server Information__") 29 | .setColor("RANDOM") 30 | .setTimestamp() 31 | .setFooter(client.user.username, client.user.displayAvatarURL()) 32 | .addFields({ 33 | name: ":hourglass: Memory Usage", 34 | value: `\`${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)}/ ${(os.totalmem() / 1024 / 1024).toFixed(2)} MB\``, 35 | inline: true 36 | }, { 37 | name: ":alarm_clock: Uptime ", 38 | value: `${getUpTime()}`, 39 | inline: true 40 | }, { 41 | name: "\u200b", 42 | value: "\u200b", 43 | inline: true 44 | }, { 45 | name: ":open_file_folder: Users", 46 | value: `\`Total: ${client.users.cache.size}\``, 47 | inline: true 48 | }, { 49 | name: ":open_file_folder: Servers", 50 | value: `\`Total: ${client.guilds.cache.size}\``, 51 | inline: true 52 | }, { 53 | name: ":open_file_folder: Voice-Channels", 54 | value: `\`Total: ${client.channels.cache.filter((ch) => ch.type === "GUILD_VOICE" || ch.type === "GUILD_STAGE_VOICE").size}\``, 55 | inline: true 56 | }, { // { name: "🔊 Connections", value: `\`${connectedchannelsamount} Connections\``, inline: true }, 57 | name: ":octopus: Discord.js", 58 | value: `\`${Discord.version == "v13.2.0-dev.1633133131.fe95005" ? "v13.2.0" : "v13.2.0"}\``, 59 | inline: true 60 | }, { 61 | name: ":four_leaf_clover: Node.js", 62 | value: `\`${process.version}\``, 63 | inline: true 64 | }, { 65 | name: "\u200b", 66 | value: "\u200b", 67 | inline: true 68 | }, { 69 | name: ":desktop: CPU", 70 | value: `\`${os.cpus().map((i) => `${i.model}`)[0] == "AMD Ryzen 5 2600 Six-Core Processor " ? "AMD Ryzen 5 2600 Six-Core Processor @ 3.90 GHz" : "Not found"}\``, 71 | inline: true 72 | }, { 73 | name: ":desktop: CPU usage", 74 | value: `\`${percent.toFixed(2)}%\``, 75 | inline: true 76 | }, { 77 | name: ":desktop: Architecture", 78 | value: `\`${os.arch()}\``, 79 | inline: true 80 | }, { 81 | name: "💻 Platform", 82 | value: `\`\`${os.platform() === "win32" ? "Windows 10 Pro 64bit" : "Not found"}\`\``, 83 | inline: true 84 | }, { 85 | name: ":incoming_envelope: Bot Latency", 86 | value: `\`${client.ws.ping}ms\``, 87 | inline: true 88 | }, { 89 | name: "\u200b", 90 | value: "\u200b", 91 | inline: true 92 | })] 93 | }); 94 | 95 | 96 | /** 97 | * 98 | * @returns time conversion to d:h:m:s 99 | */ 100 | function getUpTime() { 101 | let totalSeconds = interaction.client.uptime / 1000; 102 | const days = Math.floor(totalSeconds / 86400); 103 | totalSeconds %= 86400; 104 | const hours = Math.floor(totalSeconds / 3600); 105 | totalSeconds %= 3600; 106 | const minutes = Math.floor(totalSeconds / 60); 107 | const seconds = Math.floor(totalSeconds % 60); 108 | return uptime = `\`${days} days, ${hours} hours, ${minutes} minutes, ${seconds} seconds\``; 109 | } 110 | 111 | }); 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | } 121 | 122 | 123 | } -------------------------------------------------------------------------------- /SlashCommands/images/xkcd.js: -------------------------------------------------------------------------------- 1 | const { Client, CommandInteraction, MessageEmbed } = require("discord.js"); 2 | const { SlashCommandBuilder } = require("@discordjs/builders"); 3 | const got = require("got"); 4 | 5 | module.exports = { 6 | userPermissions: ["SEND_MESSAGES"], 7 | ...new SlashCommandBuilder() 8 | .setName("xkcd") 9 | .setDescription("Generate a random xkcd comic, a specific one by number, or the latest one") 10 | .addIntegerOption((option) => 11 | option 12 | .setName("number") 13 | .setDescription("Enter the number of the comic you want to retrieve") 14 | .setRequired(false) 15 | ).addBooleanOption((option) => 16 | option 17 | .setName("latest") 18 | .setDescription("If true, returns the latest xkcd comic") 19 | .setRequired(false) 20 | ), 21 | 22 | run: async (client, interaction, args) => { 23 | const number = interaction.options.getInteger('number'); 24 | const latest = interaction.options.getBoolean('latest'); 25 | const minIndex = 1, maxIndex = 2523; //max as of 01 oct 2021 26 | //let comicNumber; 27 | let xkcdURL = ``; 28 | 29 | 30 | // no options - random 31 | if (!number && !latest) { 32 | //comicNumber = randomNumMinToMax(minIndex, maxIndex); 33 | //xkcdURL = `https://xkcd.com/${randomNumMinToMax(minIndex, maxIndex)}/info.0.json`; 34 | return getComic(`https://xkcd.com/${randomNumMinToMax(minIndex, maxIndex)}/info.0.json`); 35 | } 36 | 37 | // latest 38 | if (!number && latest) { 39 | //comicNumber = maxIndex; 40 | //xkcdURL = `https://xkcd.com/info.0.json`; 41 | return getComic(`https://xkcd.com/info.0.json`); 42 | } 43 | 44 | // number - specific 45 | if (number && !latest) { 46 | if (number < minIndex || number > maxIndex) { 47 | return interaction.followUp({ 48 | embeds: [new MessageEmbed() 49 | .setColor("RED") 50 | .setDescription(`Invalid index \`${number}\`\n\nPick a number between \`${minIndex}\` and \`${maxIndex}\``) 51 | // .setTimestamp() 52 | // .setFooter(client.user.username, client.user.displayAvatarURL()) 53 | ] 54 | }); 55 | } 56 | //comicNumber = parseInt(number); 57 | //xkcdURL = ; 58 | return getComic(`https://xkcd.com/${parseInt(number)}/info.0.json`); 59 | } 60 | 61 | // both - error 62 | if (number && latest) { 63 | return interaction.followUp({ 64 | embeds: [new MessageEmbed() 65 | .setColor("RED") 66 | .setDescription(`Error: You can't select both options at the same time!`)] 67 | }); 68 | } 69 | 70 | /** 71 | * Fetches the xkcd API and returns an embedded follow up 72 | * @param {Link | URL} xkcdURL - the link/url for the comic 73 | * @returns embedded message 74 | */ 75 | function getComic(xkcdURL) { 76 | got(xkcdURL, { JSON: true }) 77 | .catch((err) => { 78 | return interaction.followUp({ 79 | embeds: [new MessageEmbed() 80 | .setColor("RED") 81 | .setTimestamp() 82 | .setFooter(client.user.username, client.user.displayAvatarURL()) 83 | .setDescription(`Error Message: \`${err}\``)] 84 | }); 85 | }) 86 | .then(result => { 87 | const content = JSON.parse(result.body); 88 | 89 | const xkcdNum = content.num; 90 | const xkcdTitle = content.safe_title; 91 | const xkcdImage = content.img; 92 | const xkcdYear = content.year; 93 | const xkcdMonth = content.month; 94 | const xkcdDay = content.day; 95 | const xkcdAlt = content.alt; 96 | 97 | const xkcdEmbed = new MessageEmbed() 98 | .setColor("RANDOM") 99 | .setTitle(xkcdTitle) 100 | .setDescription(`${xkcdAlt}\n`) 101 | .setImage(xkcdImage) 102 | .setTimestamp() 103 | .setFooter(client.user.username, client.user.displayAvatarURL()) 104 | .setURL(`https://xkcd.com/${xkcdNum}/`) 105 | .addFields({ 106 | name: `Comic Number`, 107 | value: `\`${xkcdNum}\``, 108 | inline: true 109 | }, { 110 | name: `Date Released`, 111 | value: `\`${xkcdYear} - ${xkcdMonth} - ${xkcdDay}\``, 112 | inline: true 113 | }) 114 | return interaction.followUp({ embeds: [xkcdEmbed] }); 115 | }); 116 | } 117 | 118 | /** 119 | * Returns a random number between the min and max values (always assumes correct input) 120 | * @param {Integer} min - minimum index number 121 | * @param {Integer} max - maximum index number 122 | * @returns random number 123 | */ 124 | function randomNumMinToMax(min, max) { 125 | return Math.floor(Math.random() * (max - min + 1) + min); 126 | } 127 | 128 | }, 129 | }; 130 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 |
3 | 4 | Keplar 5 |

6 |

A multipurpose Discord bot built with discord.js v13

7 | 8 |
9 | keplar v1.0.0 10 | node.js v16.9.1 11 | discord.js v13.2.0@dev 12 | humaiyun 13 |

14 |
15 |

Table of Contents

16 | About 17 | — 18 | Features 19 | — 20 | Set Up 21 | — 22 | Work in Progress 23 | — 24 | Showcase 25 | — 26 | License 27 | — 28 | Lessons Learned 29 |
30 |
31 |

❓ About

32 | 33 | Keplar is a personal Discord bot project that is constantly expanding. The purpose of this bot is to be a bot for use by my friends and I in our own private Discord servers. With that in mind, this bot was coded assuming it would only be used for private server use. This means the bot has no formal permission handling (e.g. `everyone`, `administrator`, `moderators`, etc.), or automated commands (e.g. `auto roles`, `command disabling`, etc.). 34 | 35 | Keplar is an ongoing project of mine and it is still under active development at the moment. 36 | 37 | I don't intend to advertise Keplar or get people to add it to their servers, as this is just a project. However, if you want to use Keplar, my recommendation is to download the source code (.zip), or clone the repository to make this a local bot on your computer. Feel free to modify the source code to your liking. 38 | 39 | ⚠ Note: There is a secondary branch, `keplar-old-framework`, which used to be the original main branch (w/ over 120 commits and featured 12+ commands). I do not recommend downloading that since it is on a roughly designed framework. The current `main` branch has a much better framework and is where all active development will be committed to. 40 | 41 | If you end up downloading, cloning, or you simply like this repository, leaving a star ⭐ is much appreciated! 42 | 43 | 44 |

📃 Features

45 | 46 | Every single command is supported with slash commands as well as prefix-based. Note: Some commands will have several options to them to allow for different types of requests. 47 | 48 | * 🎮 **Fun:** Several fun commands such as `8ball`, `advice`, and `coinflip` 49 | * 📷 **Images:** Commands that return an embedded image include `cat`, `meme`, `pokemon`, and `xkcd` 50 | * 🎶 **Music:** Play tunes and more: `play`, `currentSong`, `lyrics`, `shuffle`, `volume`, and 6 more! 51 | * 💰 **Cryptocurrency:** Get current crypto market statistics with `crypto` 52 | * ❔ **Info:** Commands include `info`, `ping`, and `stats` for general server and bot information 53 | * 🔧 **Utility:** For general utility `clear`, and `rng` 54 | * 🪀 **Misc:** Get the definitions of words with `define`, and `stats` 55 | 56 | This bot is still in very early development. More commands will be added in the future, with support for both slash, and prefix commands. 57 | 58 | 59 |

⚙ Set Up

60 | 61 | To set up Keplar for local host on your computer, you must create a `config.json` file in the root of the repository's directory. This file should be set up similarly to the example given below. **Note: You can change the prefix from `!` to whatever you want.** 62 | 63 | ```json 64 | { 65 | "token": "BOT-TOKEN", 66 | "prefix": "!", 67 | "mongooseConnectionString": "MONGODB-CONNECTION-STRING", 68 | "singleGuildId": "SERVER-ID", 69 | "apiKeys": 70 | { 71 | "key-1": "API-KEY-1", 72 | "key-2": "API-KEY-2" 73 | } 74 | } 75 | ``` 76 | In terms of how to acquire a bot token, mongoDB connection string, or external api keys, I recommend searching the internet (Google, or YouTube) for in-depth guides. There are a lot of detailed guides on getting a Discord bot set up either locally or on a host site. Example Guide 77 | 78 |

79 | Other things to install include: 80 |

85 |

86 | 87 |

🏗 Work in Progress

88 |

As previously mentioned, Keplar is in active development and will get more updates in the future.

89 |

90 | Some ideas in the works include: 91 |

95 |

96 | 97 | 98 |

🖼 Showcase

99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 |
/clear/crypto cryptocurrency:List of commands
clear commandcrypto commandfull command list
113 |
114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 |
/pokemon/pokemon index:/pokemon name:
pokemon random commandpokemon index commandpokemon name command
128 | 129 | 130 |

📝 License

131 |

132 | This project is released under the GNU GPL v3 license. Official Site. 133 |

134 | 135 |

📚 What I Learned From This Project

136 |

137 | Some of the things I learned from this project include: 138 |

146 |

147 | 148 | 149 | 150 | 151 | -------------------------------------------------------------------------------- /SlashCommands/images/pokemon.js: -------------------------------------------------------------------------------- 1 | const { Client, CommandInteraction, MessageEmbed } = require("discord.js"); 2 | const { SlashCommandBuilder } = require("@discordjs/builders"); 3 | const got = require("got"); 4 | 5 | module.exports = { 6 | userPermissions: ["SEND_MESSAGES"], 7 | ...new SlashCommandBuilder() 8 | .setName("pokemon") 9 | .setDescription("Get the information of a Pokemon. Note: Some Pokemon will not have moves to display") 10 | .addStringOption((option) => 11 | option 12 | .setName("name") 13 | .setDescription("Enter the name of the Pokemon") 14 | .setRequired(false) 15 | ) 16 | .addIntegerOption((option) => 17 | option 18 | .setName("index") 19 | .setDescription("Enter the index number of the Pokemon") 20 | .setRequired(false) 21 | ), 22 | 23 | run: async (client, interaction, args) => { 24 | 25 | const string = interaction.options.getString('name'); 26 | const integer = interaction.options.getInteger('index'); 27 | const minIndex = 1, maxIndex = 898; 28 | 29 | if (!integer && !string) return getPokemon(randomNumMinToMax(minIndex, maxIndex)); // get random 30 | if (!integer && string) return getPokemon(string); //get by name 31 | 32 | if (integer && string) { // error if both parameters are inputted 33 | return interaction.followUp({ 34 | embeds: [new MessageEmbed() 35 | .setColor("RED") 36 | .setDescription(`Error: You can't select both options at the same time!`) 37 | ] 38 | }); 39 | } 40 | 41 | if (integer && !string) { //get by index 42 | if (integer < minIndex || integer > maxIndex) { 43 | return interaction.followUp({ 44 | embeds: [new MessageEmbed() 45 | .setColor("RED") 46 | .setDescription(`Invalid index \`${integer}\`\n\nPick a number between \`${minIndex}\` and \`${maxIndex}\``) 47 | // .setTimestamp() 48 | // .setFooter(client.user.username, client.user.displayAvatarURL()) 49 | ] 50 | }); 51 | } 52 | //pokemonInput = integer; 53 | return getPokemon(integer); 54 | } 55 | 56 | /** 57 | * Returns a random number between the min and max values (always assumes correct input) 58 | * @param {Integer} min - minimum index number 59 | * @param {Integer} max - maximum index number 60 | * @returns random number 61 | */ 62 | function randomNumMinToMax(min, max) { 63 | return Math.floor(Math.random() * (max - min + 1) + min); 64 | } 65 | 66 | /** 67 | * Returns the pokemon information embed 68 | * @param {String | Integer} pokemonInput 69 | * @returns interaction followup embed of the pokemon 70 | */ 71 | function getPokemon(pokemonInput) { 72 | // get request the api 73 | got(`https://pokeapi.co/api/v2/pokemon/${pokemonInput}/`, { JSON: true }) 74 | .catch((err) => { 75 | const throwEmbed = new MessageEmbed() 76 | //.setAuthor("Error") 77 | .setColor("RED") 78 | .setTimestamp() 79 | .setFooter(client.user.username, client.user.displayAvatarURL()) 80 | .setDescription(`\`${pokemonInput}\` is an invalid Pokemon name. \n\nError Message: \`${err}\``); 81 | interaction.followUp({ embeds: [throwEmbed] }); 82 | }) 83 | .then(result => { 84 | const content = JSON.parse(result.body); 85 | 86 | const pokemonName = content.name; 87 | const pokemonType = content.types[0].type.name; 88 | const pokemonIndex = content.id; 89 | const pokemonHeight = content.height / 10.0; // height in metres 90 | const pokemonWeight = content.weight / 10.0; // weight in kg 91 | const pokemonHP = content.stats[0].base_stat; // base Health 92 | const pokemonAP = content.stats[1].base_stat; // base Attack 93 | const pokemonFrontSprite = `${content.sprites.other["official-artwork"].front_default}`; //content.sprites.front_default; 94 | //const pokemonBackSprite = content.sprites.back_default; Sprite of the back of the pokemon 95 | 96 | let arrayOfMoves = []; 97 | if (content.moves.length >= 1) { 98 | const amountOfMoves = content.moves.length; 99 | while (arrayOfMoves.length < 3) { // get 3 moves - change the number to get num amount of moves 100 | arrayOfMoves.push(content.moves[randomNumMinToMax(0, amountOfMoves - 1)].move.name); 101 | } 102 | } 103 | 104 | const pokeEmbed = new MessageEmbed() 105 | .setColor("RANDOM") 106 | .setAuthor(`${pokemonName.charAt(0).toUpperCase() + pokemonName.slice(1)}`, `${pokemonFrontSprite}`, `https://pokemon.fandom.com/wiki/${pokemonName}`) 107 | .setImage(`${pokemonFrontSprite}`) 108 | .setTimestamp() 109 | .setFooter(client.user.username, client.user.displayAvatarURL()) 110 | .setFields({ 111 | name: "Index", 112 | value: `\`\`\`${pokemonIndex}\`\`\``, 113 | inline: true 114 | }, { 115 | name: `Height`, 116 | value: `\`\`\`${pokemonHeight} m\`\`\``, 117 | inline: true 118 | }, { 119 | name: "Weight", 120 | value: `\`\`\`${pokemonWeight} kg\`\`\``, 121 | inline: true 122 | }, { 123 | name: "Type", 124 | value: `\`\`\`${pokemonType}\`\`\``, 125 | inline: true 126 | }, { 127 | name: "Base Health", 128 | value: `\`\`\`${pokemonHP}\`\`\``, 129 | inline: true 130 | }, { 131 | name: "Base Attack", 132 | value: `\`\`\`${pokemonAP}\`\`\``, 133 | inline: true 134 | }); 135 | 136 | for (let i = 0; i < arrayOfMoves.length; i++) { 137 | pokeEmbed.addFields({ 138 | name: `Move ${i + 1}`, 139 | value: `\`\`\`${arrayOfMoves[i] === undefined ? "N/A" : arrayOfMoves[i]}\`\`\``, 140 | inline: true 141 | }); 142 | } 143 | return interaction.followUp({ embeds: [pokeEmbed] }); 144 | }); 145 | } 146 | }, 147 | }; 148 | 149 | -------------------------------------------------------------------------------- /SlashCommands/cryptocurrency/crypto.js: -------------------------------------------------------------------------------- 1 | 2 | const { Client, CommandInteraction, MessageEmbed } = require("discord.js"); 3 | const { SlashCommandBuilder } = require("@discordjs/builders"); 4 | const got = require("got"); 5 | 6 | module.exports = { 7 | userPermissions: ["SEND_MESSAGES"], 8 | ...new SlashCommandBuilder() 9 | .setName("crypto") 10 | .setDescription(`Get the latest market information for various cryptocurrencies. Supports the top 200 coins`) 11 | .addStringOption((option) => 12 | option 13 | .setName("cryptocurrency") 14 | .setDescription("Enter the full name or symbol to get information of that coin") 15 | .setRequired(false) 16 | ) 17 | .addBooleanOption((option) => 18 | option 19 | .setName("list") 20 | .setDescription("If true, returns a list of the top 200 crypto's by their symbol") 21 | .setRequired(false) 22 | ), 23 | 24 | 25 | run: async (client, interaction, args) => { 26 | 27 | let coinGeckoURL = `https://api.coingecko.com/api/v3/`; // `${coinGeckoURL}/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=24&page=1&sparkline=false`; 28 | 29 | const str = interaction.options.getString("cryptocurrency"); 30 | const bool = interaction.options.getBoolean("list"); 31 | //console.log(`integer: ${integer} str: ${str}`); 32 | 33 | if (!str && !bool) { // if both null 34 | coinGeckoURL = `${coinGeckoURL}/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=24&page=1&sparkline=false`; 35 | got(coinGeckoURL, { JSON: true }) 36 | .catch((err) => { 37 | const throwEmbed = new MessageEmbed() 38 | .setColor("RED") 39 | .setDescription(`Error Message: \`${err}\``); 40 | interaction.followUp({ embeds: [throwEmbed] }); 41 | }) 42 | .then(result => { 43 | const content = JSON.parse(result.body); 44 | getCryptoListEmbed(content); 45 | }); 46 | } 47 | 48 | else if (bool && !str) { // list 49 | coinGeckoURL = `${coinGeckoURL}/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=201&page=1&sparkline=false`; 50 | got(coinGeckoURL, { JSON: true }) 51 | .catch((err) => { 52 | const throwEmbed = new MessageEmbed() 53 | .setColor("RED") 54 | .setDescription(`Error Message: \`${err}\``); 55 | interaction.followUp({ embeds: [throwEmbed] }); 56 | }) 57 | .then(result => { 58 | const content = JSON.parse(result.body); 59 | const cryptoSymbol = []; 60 | for (let i = 0; i < content.length; i++) { 61 | cryptoSymbol.push(content[i].symbol.toUpperCase()); 62 | } 63 | let coinListEmbed = new MessageEmbed() 64 | .setTitle(":coin: Top 200 Cryptocurrency Symbols in Order of Market Cap") 65 | .setTimestamp() 66 | .setFooter(client.user.username, client.user.displayAvatarURL()); 67 | 68 | let tempStr = `| `; 69 | for (let i = 0; i < cryptoSymbol.length; i++) { 70 | tempStr += `\`${cryptoSymbol[i]}\` | `; 71 | } 72 | coinListEmbed.setDescription(tempStr); 73 | return interaction.followUp({ embeds: [coinListEmbed] }); 74 | }); 75 | } 76 | 77 | else if (str && !bool) { // crypto name or symbol 78 | coinGeckoURL = `${coinGeckoURL}/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=201&page=1&sparkline=false`; 79 | getCoin(coinGeckoURL, str.toLowerCase()); 80 | } 81 | 82 | else if (str && bool) { // throw error if both commands picked at the same time 83 | const throwEmbed = new MessageEmbed() 84 | .setColor("RED") 85 | .setDescription(`Error: You can't select both options at the same time!`); 86 | interaction.followUp({ embeds: [throwEmbed] }); 87 | } 88 | 89 | 90 | 91 | 92 | 93 | /** 94 | * Get the list of the top 24 cryptocurrency by total market cap. Returns an embedded message. 95 | * @param {JSON} content 96 | * @returns list of top 24 crypto in a discord embedded message 97 | */ 98 | function getCryptoListEmbed(content) { 99 | const cryptoName = []; 100 | const cryptoSymbol = []; 101 | const cryptoPrice = []; 102 | const cryptoImage = []; 103 | for (let i = 0; i < content.length; i++) { 104 | cryptoName.push(content[i].id); 105 | cryptoSymbol.push(content[i].symbol); 106 | cryptoPrice.push(content[i].current_price); 107 | cryptoImage.push(content[i].image); 108 | } 109 | let coinListEmbed = new MessageEmbed() 110 | .setTitle("Top Cryptocurrency by Market Cap") 111 | .setDescription(`All prices are in \`USD\` :money_with_wings: \n[Data Provided by CoinGecko](https://www.coingecko.com/en)\n\n`) 112 | .setTimestamp() 113 | .setFooter(client.user.username, client.user.displayAvatarURL()); 114 | 115 | for (let j = 0; j < cryptoName.length; j++) { 116 | coinListEmbed.addFields({ 117 | name: `${j + 1}. ${cryptoName[j].charAt(0).toUpperCase() + cryptoName[j].slice(1)}`, 118 | value: `\`${cryptoSymbol[j].toUpperCase()}\` → \`$${cryptoPrice[j].toString()}\``, 119 | inline: true 120 | }); 121 | } 122 | return interaction.followUp({ embeds: [coinListEmbed] }); 123 | } 124 | 125 | 126 | /** 127 | * Cycles through the JSON via HTTPS GET Request then checks for the key and values with respect to the input. 128 | * Returns the coin info if found, otherwise returns an error embed 129 | * @param {JSON | URL | string} content 130 | * @param {string} input {user input from the slash command options/parameters} 131 | * @returns an embedded message about the specific crypto coin 132 | */ 133 | function getCoin(content, input) { 134 | got(content, { JSON: true }) 135 | .catch((err) => { 136 | const throwEmbed = new MessageEmbed() 137 | .setAuthor("Error") 138 | .setColor("RED") 139 | .setDescription(`Error Message: \`${err}\``); 140 | interaction.followUp({ embeds: [throwEmbed] }); 141 | }) 142 | .then(result => { 143 | const content = JSON.parse(result.body); 144 | let count = 1; 145 | 146 | //"key" is the JSON index 147 | for (const key in content) { 148 | if (content[key].id == input || content[key].symbol == input) { 149 | return getSpecificCoinInfoEmbed(content, key); 150 | } 151 | count++; 152 | } 153 | if (count > 199) { 154 | const invalidEmbed = new MessageEmbed() 155 | .setColor("RED") 156 | // .setTimestamp() 157 | // .setFooter(client.user.username, client.user.displayAvatarURL()) 158 | .setDescription(`\`${input}\` is an invalid name or symbol\n`); 159 | return interaction.followUp({ embeds: [invalidEmbed] }); 160 | } 161 | }); 162 | } 163 | 164 | /** 165 | * Get detailed info of a specific cryptocurrency. Returns an embedded message. 166 | * @param {JSON} content 167 | * @param {string} coinIndex 168 | * @returns detailed info of a specific crypto and returns it in a discord embedded message 169 | */ 170 | function getSpecificCoinInfoEmbed(content, coinIndex) { 171 | const cryptoName = content[coinIndex].id.charAt(0).toUpperCase() + content[coinIndex].id.slice(1); 172 | const cryptoSymbol = content[coinIndex].symbol.toUpperCase(); 173 | const cryptoImage = content[coinIndex].image; 174 | //const cryptoLastUpdated = content[coinIndex].last_updated; 175 | const cryptoRank = content[coinIndex].market_cap_rank; 176 | 177 | const cryptoPriceChange24h = content[coinIndex].price_change_percentage_24h; 178 | const cryptoPercentChange24h = new Intl.NumberFormat("en-CA", { 179 | style: "currency", 180 | currency: "USD" 181 | }).format(content[coinIndex].price_change_24h); 182 | 183 | const cryptoPrice = new Intl.NumberFormat("en-CA", { 184 | style: "currency", 185 | currency: "USD" 186 | }).format(content[coinIndex].current_price); 187 | const cryptoHigh24 = new Intl.NumberFormat("en-CA", { 188 | style: "currency", 189 | currency: "USD" 190 | }).format(content[coinIndex].high_24h); 191 | const cryptoLow24 = new Intl.NumberFormat("en-CA", { 192 | style: "currency", 193 | currency: "USD" 194 | }).format(content[coinIndex].low_24h); 195 | const cryptoMarketCap = new Intl.NumberFormat("en-CA", { 196 | style: "currency", 197 | currency: "USD" 198 | }).format(content[coinIndex].market_cap); 199 | const cryptoAllTimeHigh = new Intl.NumberFormat("en-CA", { 200 | style: "currency", 201 | currency: "USD" 202 | }).format(content[coinIndex].ath); 203 | 204 | let cryptoEmbed = new MessageEmbed() 205 | .setAuthor(`${cryptoName} (${cryptoSymbol})`, cryptoImage) 206 | .setTimestamp() 207 | .setColor("RANDOM") 208 | .setFooter(client.user.username, client.user.displayAvatarURL()) 209 | .setFields({ 210 | name: ":first_place: Rank", 211 | value: `\`\`\`${cryptoRank}\`\`\``, 212 | inline: true 213 | }, { 214 | name: ":dollar: Currect Price", 215 | value: `\`\`\`${cryptoPrice}\`\`\``, 216 | inline: true 217 | }, { 218 | name: "📊 All Time High", 219 | value: `\`\`\`${cryptoAllTimeHigh}\`\`\``, 220 | inline: true 221 | }, { 222 | name: `:chart_with_upwards_trend: 24 Hour High`, 223 | value: `\`\`\`${cryptoHigh24}\`\`\``, 224 | inline: true 225 | }, { 226 | name: ":chart_with_downwards_trend: 24 Hour Low", 227 | value: `\`\`\`${cryptoLow24}\`\`\``, 228 | inline: true 229 | }, { 230 | name: ":chart: Market Cap", 231 | value: `\`\`\`${cryptoMarketCap}\`\`\``, 232 | inline: true 233 | }); 234 | return interaction.followUp({ embeds: [cryptoEmbed] }) 235 | } 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | }, 258 | }; -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------