LittleSpace Network Developers
Sign in

Sending messages

Everything the bot sends goes through bot.rest. Each call returns what Fluxer sends back, usually the message.

#Text

JavaScript
await bot.rest.sendMessage(channelId, 'Good morning, littles ☀️');

Bots can send up to 4,000 characters in one message.

#Replies

Inside a command, use reply. Anywhere else, use bot.reply with the message you’re answering:

JavaScript
bot.on('message', async (message) => {
  if (message.content.toLowerCase() === 'goodnight') {
    await bot.reply(message, 'Goodnight! 🌙');
  }
});

Replies don’t ping the person by default. To ping them, pass an object:

JavaScript
await bot.reply(message, { content: 'Your turn!', allowed_mentions: { replied_user: true } });

#Embeds

JavaScript
await bot.rest.sendMessage(channelId, {
  embeds: [{
    title: 'Story time',
    description: 'Tonight’s story is **The Sleepy Lion Cub**.',
    color: 0xa98bf5,
    fields: [
      { name: 'Starts', value: '8:00 PM', inline: true },
      { name: 'Channel', value: '#storytime', inline: true },
    ],
    footer: { text: 'Bring a blanket' },
  }],
});

Embeds need the Embed links permission. A message can have text, embeds, or both.

#Mentions

By default, a mention in the text notifies the person. To send a message that mentions someone without pinging anyone:

JavaScript
await bot.rest.sendMessage(channelId, {
  content: `<@${userId}> earned a gold star ⭐`,
  allowed_mentions: { parse: [] },
});

#Reactions

JavaScript
await bot.rest.react(message.channel_id, message.id, '🧸');

For a custom emoji, pass name:id, like bwah:1234567890.

#Editing and deleting

JavaScript
const sent = await bot.rest.sendMessage(channelId, 'Counting…');
await bot.rest.editMessage(channelId, sent.id, 'Done counting!');

await bot.rest.deleteMessage(channelId, sent.id);

Deleting someone else’s message needs Manage messages. Add a reason and it shows in the audit log:

JavaScript
await bot.rest.deleteMessage(message.channel_id, message.id, 'Only bwahs in #bwah');

#DMs

Open a DM channel first, then send to it:

JavaScript
const dm = await bot.rest.createDM(userId);
await bot.rest.sendMessage(dm.id, 'Here’s your reminder to drink some water 💧');

If the person has blocked the bot, sending fails with CANNOT_SEND_MESSAGES_TO_USER.

#Anything else

bot.rest can call any route in the Fluxer API docs:

JavaScript
const pins = await bot.rest.get(`/channels/${channelId}/messages/pins`);
await bot.rest.put(`/guilds/${guildId}/members/${userId}/roles/${roleId}`, undefined, { reason: 'Reaction role' });

Rate limits are handled for you. If Fluxer says to wait, fluxkit waits and tries again, and a retried message is never sent twice.