Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const moment = require('moment')
- const util = require("util");
- const Eris = require("eris")
- const axios = require('axios')
- const Permissions = require('eris').Constants.Permissions;
- var bot = new
- Eris.CommandClient("BOT_TOKEN", {}, {
- description: "A test bot made entirely",
- owner: "Axiatinc",
- prefix: "!"
- });
- bot.on("ready", () => {
- console.log("Ready!");
- })
- bot.registerCommand("about", "**About this bot:** \n This bot was coded by Juuzou Suzuya, using the **Eris** library by abalabahaha, in JavaScript\n \n For more information, contact Juuzou Suzuya#6044, or join our support server here: https://discord.gg/QtQBHcW", {
- description: "About",
- fullDescription: "This command gives you information about the bot."
- });
- var echoCommand = bot.registerCommand("echo", (msg, args) => { // Make an echo command
- if(args.length === 0) { // If the user just typed "!echo", say "Invalid input"
- return "Invalid input";
- }
- var text = args.join(" "); // Make a string of the text after the command label
- return text; // Return the generated string
- }, {
- description: "Make the bot say something",
- fullDescription: "The bot will echo whatever is after the command label.",
- usage: "<text>"
- });
- //Kick command
- //Usage: !kick @Username
- bot.registerCommand("kick", (msg, args) => {
- bot.kickGuildMember(msg.channel.guild.id, msg.mentions[0].id);
- bot.createMessage(msg.channel.id, "Kicked user " + msg.mentions[0].username);
- },{
- requirements: {
- permissions: {
- "kickMembers": true
- }
- }
- });
- bot.registerCommand("invite", (msg) => {
- bot.createMessage(msg.channel.id, "**Hello!** | I see you want to invite me to your server! Well heres the link: https://discordapp.com/oauth2/authorize?client_id=401844837793660939&scope=bot&permissions=2146958591");
- },{
- description: "Get the discord bots invite link",
- fullDescription: "Invite HexBot to your discord server, so you can use it yourself!"
- });
- //Ban Command
- //Usage: !ban @Username
- bot.registerCommand("ban", (msg, args) => {
- bot.banGuildMember(msg.channel.guild.id, msg.mentions[0].id);
- bot.createMessage(msg.channel.id, "Banned user " + msg.mentions[0].username);
- },{
- requirements: {
- permissions: {
- "banMembers": true
- }
- }
- });
- module.exports = {
- process: async message => {
- let guild = message.channel.guild, channel = message.channel, author = message.author, member = message.member; // eslint-disable-line
- try {
- let output = await eval(`(async function(){${message.args[0].replace(/“|”/g, "\"")}}).call()`);
- output = util.inspect(output, { depth: 0 }).substring(0, 1900);
- return `:white_check_mark: **Output:** ${bot.utils.codeBlock(output, "js")}`;
- } catch(error) {
- return `:x: **Error:** ${bot.utils.codeBlock(error)}`;
- }
- },
- caseSensitive: true,
- description: "Execute code",
- args: [{
- type: "text",
- label: "code"
- }]
- };
- echoCommand.registerSubcommand("reverse", (msg, args) => { // Make a reverse subcommand under echo
- if(args.length === 0) { // If the user just typed "!echo reverse", say "Invalid input"
- return "Invalid input";
- }
- var text = args.join(" "); // Make a string of the text after the command label
- text = text.split("").reverse().join(""); // Reverse the string
- return text; // Return the generated string
- }, {
- description: "Make the bot say something in reverse",
- fullDescription: "The bot will echo, in reverse, whatever is after the command label.",
- usage: "<text>"
- });
- echoCommand.registerSubcommandAlias("backwards", "reverse"); // Alias "!echo backwards" to "!echo reverse"
- let clean = bot.registerCommand('clean', (msg, args) => {
- let toDelete = parseInt(args.length > 0 ? args[0] : 10);
- if(!toDelete) return 'Please supply a valid number';
- bot.purgeChannel(msg.channel.id, toDelete + 1).then(del => {
- bot.createMessage(msg.channel.id, `${del - 1} messages deleted`).then(msg => {
- setTimeout(() => bot.deleteMessage(msg.channel.id, msg.id), 4000);
- });
- });
- }, {
- description: 'Deletes messages',
- fullDescription: 'The bot will delete messages from all users in the last specified number of messages',
- usage: '<number to search through>',
- requirements: {
- permissions: {
- "manageMessages": true
- }
- }
- });
- bot.registerCommand('ping', (msg, args) => {
- bot.createMessage(msg.channel.id, 'pong').
- then(newMsg => {
- bot.editMessage(newMsg.channel.id, newMsg.id, `\`\`\`javascript\npong | Time taken: ${newMsg.timestamp - msg.timestamp} ms\`\`\``);
- });
- }, {
- description: 'Ping me to make sure I\'m alive',
- fullDescription: 'The bot will reply with the amount of time taken'
- });
- bot.registerCommand('uptime', (msg, args) => {
- let totalSeconds = process.uptime();
- let days = Math.floor(totalSeconds / 86400);
- totalSeconds %= 86400;
- let hours = Math.floor(totalSeconds / 3600);
- totalSeconds %= 3600;
- let minutes = Math.floor(totalSeconds / 60);
- let seconds = Math.floor(totalSeconds % 60);
- bot.createMessage(msg.channel.id, `\`${days} days, ${hours} hrs, ${minutes} min, ${seconds} sec\``);
- }, {
- description: 'Check my uptime',
- fullDescription: 'The bot will reply with the amount of time it has been available'
- });
- bot.registerCommand('mute', (msg, args) => {
- if(args.length === 0) return 'Please supply a user to mute';
- let toFind = bot.users.find(u => u.username === args[0]);
- if(!toFind) return 'Please supply a valid user';
- bot.editChannelPermissions(msg.channel.id, msg.author.id, 0, Permissions.sendMessages);
- }, {
- description: 'Mutes a user',
- fullDescription: 'Mutes a user so they will not be able to send messages in their current channel',
- usage: '<number to search through>',
- requirements: {
- permissions: {
- "manageMessages": true
- }
- }
- });
- bot.registerCommand('roll', (msg, args) => {
- if(args.length === 0) return Math.floor(Math.random() * 100000) + 1;
- let roll = parseInt(args[0]);
- if(!roll) return 'Please supply a number';
- return Math.floor(Math.random() * roll) + 1;
- }, {
- description: 'Roll a 100000sided die',
- fullDescription: 'Have the bot roll a number between 0 and 100, or a different specified max',
- usage: '<max number for roll>'
- });
- bot.registerCommand('movie', (msg, args) => {
- axios
- .get(`https://api.themoviedb.org/3/search/movie?api_key=${'18098c7fa8072885bb609c96512e1d32'}&query=${args}`)
- .then(response => {
- axios
- .get(`https://api.themoviedb.org/3/movie/${response.data.results[0].id}?api_key=${'18098c7fa8072885bb609c96512e1d32'}&language=en-US`)
- .then(response => {
- const embed = {
- author: {
- name: response.data.original_title,
- icon_url: 'https://www.themoviedb.org/assets/static_cache/2dceae11589334eecd61443249261daf/images/v4/logos/208x226-stacked-green.png',
- url: response.data.homepage !== null ? response.data.homepage : ''
- },
- title: 'Movie Information:',
- color: 16765404,
- fields: [
- {
- name: 'Release Date',
- value: response.data.release_date !== null ? response.data.release_date : 'N/A',
- inline: true
- },
- {
- name: 'Vote Average',
- value: response.data.vote_average.toString() !== null ? response.data.vote_average.toString() : 'N/A',
- inline: true
- },
- {
- name: 'Status',
- value: response.data.status !== null ? response.data.status : 'N/A',
- inline: true
- },
- {
- name: 'Runtime',
- value: response.data.runtime.toString() !== null ? response.data.runtime.toString() + ' min' : 'N/A',
- inline: true
- },
- {
- name: 'Genre',
- value: response.data.genres[0].name !== null ? response.data.genres[0].name : 'N/A',
- inline: true
- },
- {
- name: 'Production Company',
- value: response.data.production_companies[0].name !== null ? response.data.production_companies[0].name : 'N/A',
- inline: true
- },
- {
- name: 'Language',
- value: response.data.original_language !== null ? response.data.original_language : 'N/A',
- inline: true
- },
- {
- name: 'Country',
- value: response.data.production_countries[0].name !== null ? response.data.production_countries[0].name : 'N/A',
- inline: true
- },
- {
- name: 'Plot',
- value: response.data.overview !== null ? response.data.overview : 'N/A',
- inline: false
- }
- ],
- thumbnail: {
- url: response.data.poster_path !== null ? 'https://image.tmdb.org/t/p/w500' + response.data.poster_path : 'https://www.themoviedb.org/assets/static_cache/2dceae11589334eecd61443249261daf/images/v4/logos/208x226-stacked-green.png'
- },
- timestamp: new Date(),
- footer: {
- icon_url: bot.user.avatarURL,
- text: bot.user.username
- }
- }
- bot.createMessage(msg.channel.id, {
- embed: embed
- })
- })
- })
- })
- bot.registerCommand('anime', (msg, args) => {
- axios
- .get(`https://kitsu.io/api/edge/anime?filter[text]=${args}`)
- .then(response => {
- const embed = {
- author: {
- name: response.data.data[0].attributes.titles.en,
- icon_url:
- 'https://pbs.twimg.com/profile_images/807964865511862278/pIYOVdsl_400x400.jpg',
- url: `https://kitsu.io/anime/${response.data.data[0].attributes.slug}`
- },
- title: 'Anime Information:',
- color: 16765404,
- fields: [
- {
- name: 'Episode Count',
- value: response.data.data[0].attributes.episodeCount != null ? response.data.data[0].attributes.episodeCount.toString() : 'None',
- inline: true
- },
- {
- name: 'Episode Length',
- value: response.data.data[0].attributes.episodeLength != null ? response.data.data[0].attributes.episodeLength.toString() : 'None',
- inline: true
- },
- {
- name: 'Started Airing',
- value: response.data.data[0].attributes.startDate != null ? response.data.data[0].attributes.startDate : 'None',
- inline: true
- },
- {
- name: 'Finished Airing',
- value: response.data.data[0].attributes.endDate != null ? response.data.data[0].attributes.endDate : 'None',
- inline: true
- },
- {
- name: 'Kitsu.io Rating',
- value: response.data.data[0].attributes.averageRating != null ? response.data.data[0].attributes.averageRating.toString() : 'None',
- inline: true
- },
- {
- name: 'Age Rating',
- value: response.data.data[0].attributes.ageRating != null ? response.data.data[0].attributes.ageRating : 'None',
- inline: true
- },
- {
- name: 'Synopsis',
- value: response.data.data[0].attributes.synopsis != null ? response.data.data[0].attributes.synopsis : 'None',
- inline: false
- }
- ],
- thumbnail: {
- url: response.data.data[0].attributes.posterImage.medium
- },
- timestamp: new Date(),
- footer: {
- icon_url: bot.user.avatarURL,
- text: bot.user.username
- }
- }
- // Create message
- bot.createMessage(msg.channel.id, {
- embed: embed
- })
- })
- })
- bot.connect();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement