Skip to content

Instantly share code, notes, and snippets.

@CallumDenby
Created October 18, 2018 13:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CallumDenby/45147b62d281c39067595c1c1202220a to your computer and use it in GitHub Desktop.
Save CallumDenby/45147b62d281c39067595c1c1202220a to your computer and use it in GitHub Desktop.
const { Client } = require('discord.js');
const Discord = new Client();
const commands = {
steal: (emoji, name, message) => {
const emojiId = emoji.match(/([0-9]+)/)[0];
if (!emojiId) return message.reply('Emoji ID not found');
message.guild.createEmoji(`https://cdn.discordapp.com/emojis/${emojiId}`, name)
.then((newEmoji) => {
message.react(newEmoji);
})
.catch((err) => {
console.error(err);
message.react('👎');
})
}
}
Discord.on('message', (message) => {
if (!message.content.startsWith(':')) return;
const content = message.content.substring(1);
const [command, ...args] = content.split(' ');
if (command in commands) commands[command](...args, message);
else message.reply('Command not found');
})
Discord.on('ready', () => {
console.log(`Logged in as ${Discord.user.username}`);
})
Discord.login('BOT_TOKEN');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment