Skip to content

@lunibee/structures

The @lunibee/structures package wraps raw Discord API JSON objects in rich, strongly-typed domain model classes with utility methods.

Terminal window
bun add @lunibee/structures

Channels expose Lunibee’s resource-oriented API. You can perform common channel operations directly on the structure without reaching into client.rest.

// Send a message
const message = await channel.send({
content: "Ticket created!",
});
// Edit channel properties
await channel.edit({ topic: "Support ticket" });
// Convenience helpers
await channel.editName("support-123");
await channel.editTopic("Support ticket");
await channel.editParent(categoryId);
// Delete the channel
await channel.delete();

client.rest remains available when you need direct access to an endpoint that is not represented by a resource method.


Messages provide their own resource operations and expose the originating channel through message.channel.

// Access the channel that contains the message
const channel = message.channel;
// Edit message
await message.edit({ content: "Updated content" });
// Update message using Lunibee's resource API
await message.update({ content: "Updated again" });
// Reply directly to a message
await message.reply({ content: "Pong!" });
// Delete message
await message.delete();
// Add reactions
await message.react("👍");
// Pin message
await message.pin();

Resource methods require the structure to be attached to a Lunibee client context. Calling a resource operation on a detached structure throws an Error rather than silently issuing a request without the required client context.


import { GuildMember } from "@lunibee/structures";
console.log(member.displayName);
console.log(member.joinedAt);
if (member.permissions.administrator) {
console.log("Member is an admin!");
}
await member.kick("Reason");
await member.ban({ reason: "Banned" });
await member.timeout(60_000);

Other exported structures include Emoji, Webhook, and Invite.

import { Emoji, Webhook, Invite } from "@lunibee/structures";
// Use emoji fields and methods
console.log(emoji.name);
console.log(emoji.url());
// Use webhook URL or avatar
console.log(webhook.url);
console.log(webhook.avatarURL());
// Use invite fields
console.log(invite.code);
console.log(invite.url);