A Guide to Discord Bots

Custom & Animated Emojis

Now this is something that not everyone know about, but it can make your bot unique.
Your bot can use any emoji, even animated ones, from any server it is in.

Note: custom emojis are stored by their IDs at the following URLs: https://cdn.discordapp.com/emojis/EMOJI\_ID_HERE.png https://cdn.discordapp.com/emojis/EMOJI\_ID_HERE.gif (animated emojis only)

Discord & Unicode Emojis

client.on('ready', () => {
    // Nothing special, users can do it too
    let channel = client.guilds.get('guild_id').channels.get('channel_id');
    channel.send('A Unicode emoji: \:thumbsup:' + 
        '\nA Discord emoji: :thumbsup:');
});

Custom Emojis

First, select a custom emoji and send it with a \ before it, like with Unicode emojis.
Then, paste it into your code.

client.on('ready', () => {
    // Custom emojis are made like this:
    // <:name:ID>
    // If animated:
    // <a:name:ID>

    let channel = client.guilds.get('guild_id').channels.get('channel_id');
    channel.send('A custom emoji: <:Heart:301014681663832065>' + 
        '\nA custom **animated** emoji: <a:mop:428629994126704652>');
});

Getting IDs easily

If you don't have nitro, you can't send animated emojis to check their ID...
Good thing you have a bot!

client.on('ready', () => {
    // Custom emojis are made like this:
    // <:name:ID>
    // If animated:
    // <a:name:ID>

    // Getting all emojis from a server
    client.guilds.get('guild_id').emojis.forEach(emoji => console.log(emoji.animated ? '<a:' + emoji.name + ':' + emoji.id + '>' : '<:' + emoji.name + ':' + emoji.id + '>'));

    // A fancier way
    let static = [], animated = [];
    client.guilds.get('guild_id').emojis.forEach(emoji => emoji.animated ? animated.push([emoji.id, emoji.name]) : static.push([emoji.id, emoji.name]));

    console.log('Static Emojis\n');
    static.forEach(emoji => console.log('<:' + emoji[1] + ':' + emoji[0] + '>'));
    console.log('\nAnimated Emojis\n');
    animated.forEach(emoji => console.log('<a:' + emoji[1] + ':' + emoji[0] + '>'));

    // You can copy/paste the emojis you want into your code
    // It will not work if you paste them into Discord
});

Now, you can just make server only for your bot, and put emojis in them! Enjoy ^.^

results matching ""

    No results matching ""