@lunibee/structures
The @lunibee/structures package wraps raw Discord API JSON objects in rich, strongly-typed domain model classes with utility methods.
Installation
Section titled “Installation”bun add @lunibee/structuresChannel
Section titled “Channel”Channels expose Lunibee’s resource-oriented API. You can perform common channel operations directly on the structure without reaching into client.rest.
// Send a messageconst message = await channel.send({ content: "Ticket created!",});
// Edit channel propertiesawait channel.edit({ topic: "Support ticket" });
// Convenience helpersawait channel.editName("support-123");await channel.editTopic("Support ticket");await channel.editParent(categoryId);
// Delete the channelawait channel.delete();client.rest remains available when you need direct access to an endpoint that is not represented by a resource method.
Channel classes
Section titled “Channel classes”createChannel(data) returns TextChannel, NewsChannel, DMChannel, VoiceChannel,
StageChannel, CategoryChannel, ThreadChannel, ForumChannel or MediaChannel, all
subclasses of Channel. Use isThread(), isTextBased(), isVoiceBased() and
isDMBased() to narrow. See Caching & Structures.
Message
Section titled “Message”Messages provide their own resource operations and expose the originating channel through message.channel.
// Access the channel that contains the messageconst channel = message.channel;
// Edit messageawait message.edit({ content: "Updated content" });
// Update message using Lunibee's resource APIawait message.update({ content: "Updated again" });
// Reply directly to a messageawait message.reply({ content: "Pong!" });
// Delete messageawait message.delete();
// Add reactionsawait message.react("👍");
// Pin messageawait message.pin();Resource context errors
Section titled “Resource context errors”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.
GuildMember
Section titled “GuildMember”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);Emoji, Webhook, and Invite
Section titled “Emoji, Webhook, and Invite”Other exported structures include Emoji, Webhook, and Invite.
import { Emoji, Webhook, Invite } from "@lunibee/structures";
// Use emoji fields and methodsconsole.log(emoji.name);console.log(emoji.url());
// Use webhook URL or avatarconsole.log(webhook.url);console.log(webhook.avatarURL());
// Use invite fieldsconsole.log(invite.code);console.log(invite.url);What’s New in 0.2.0
Section titled “What’s New in 0.2.0”Interaction fetchReply(), editFollowUp(), deleteFollowUp(), user, member, expiry helpers and a single acknowledgement guard; typed channel.permissionOverwrites.