agentleFS
agentsdanceagentsdance/agentskills/skills/discord-bot-builder/SKILL.md

discord-bot-builder

Skill3 starsChanged 11 months agoApache-2.0View on GitHub

Build Discord bots. Use when the user needs to create Discord applications, handle commands, or automate Discord server tasks.

  • Reads credentials

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Create Discord bots with discord.js.

    line 8

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Discord Bot Builder

Create Discord bots with discord.js.

Setup

import { Client, GatewayIntentBits, Events, SlashCommandBuilder, REST, Routes } from 'discord.js';

const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.MessageContent,
  ],
});

client.once(Events.ClientReady, (c) => {
  console.log(`Ready! Logged in as ${c.user.tag}`);
});

client.login(process.env.DISCORD_TOKEN);

Slash Commands

Register Commands

const commands = [
  new SlashCommandBuilder()
    .setName('ping')
    .setDescription('Replies with Pong!'),

  new SlashCommandBuilder()
    .setName('user')
    .setDescription('Get user info')
    .addUserOption(option =>
      option.setName('target')
        .setDescription('The user to get info about')
        .setRequired(true)),

  new SlashCommandBuilder()
    .setName('poll')
    .setDescription('Create a poll')
    .addStringOption(option =>
      option.setName('question')
        .setDescription('The poll question')
        .setRequired(true))
    .addStringOption(option =>
      option.setName('options')
        .setDescription('Comma-separated options')
        .setRequired(true)),
];

const rest = new REST().setToken(process.env.DISCORD_TOKEN);

// Register commands
await rest.put(
  Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID),
  { body: commands.map(c => c.toJSON()) }
);

Handle Commands

client.on(Events.InteractionCreate, async (interaction) => {
  if (!interaction.isChatInputCommand()) return;

  switch (interaction.commandName) {
    case 'ping':
      await interaction.reply('Pong! 🏓');
      break;

    case 'user':
      const user = interaction.options.getUser('target');
      await interaction.reply(`User: ${user.tag}\nID: ${user.id}`);
      break;

    case 'poll':
      const question = interaction.options.getString('question');
      const options = interaction.options.getString('options').split(',');
      const emojis = ['1️⃣', '2️⃣', '3️⃣', '4️⃣', '5️⃣'];

      const pollText = options
        .map((opt, i) => `${emojis[i]} ${opt.trim()}`)
        .join('\n');

      const message = await interaction.reply({
        content: `**Poll: ${question}**\n\n${pollText}`,
        fetchReply: true,
      });

      for (let i = 0; i < options.length; i++) {
        await message.react(emojis[i]);
      }
      break;
  }
});

Message Events

client.on(Events.MessageCreate, async (message) => {
  if (message.author.bot) return;

  // Keyword response
  if (message.content.toLowerCase() === 'hello') {
    await message.reply('Hello there! 👋');
  }

  // Mention response
  if (message.mentions.has(client.user)) {
    await message.reply('You mentioned me!');
  }
});

Embeds

import { EmbedBuilder } from 'discord.js';

const embed = new EmbedBuilder()
  .setColor(0x0099FF)
  .setTitle('Server Info')
  .setDescription('Information about this server')
  .setThumbnail(interaction.guild.iconURL())
  .addFields(
    { name: 'Members', value: `${interaction.guild.memberCount}`, inline: true },
    { name: 'Created', value: interaction.guild.createdAt.toDateString(), inline: true },
  )
  .setTimestamp();

await interaction.reply({ embeds: [embed] });

Buttons & Select Menus

import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from 'discord.js';

const row = new ActionRowBuilder()
  .addComponents(
    new ButtonBuilder()
      .setCustomId('approve')
      .setLabel('Approve')
      .setStyle(ButtonStyle.Success),
    new ButtonBuilder()
      .setCustomId('deny')
      .setLabel('Deny')
      .setStyle(ButtonStyle.Danger),
  );

await interaction.reply({ content: 'Please approve:', components: [row] });

// Handle button click
client.on(Events.InteractionCreate, async (interaction) => {
  if (!interaction.isButton()) return;

  if (interaction.customId === 'approve') {
    await interaction.update({ content: 'Approved!', components: [] });
  }
});

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.