Skip to main content
Deno 2 is finally here 🎉️
Learn more

Getting Started

Here is a minimal example to create and show modal:

import { createModal } from "https://deno.land/x/discord_tools@v1.0.8/mod.ts";

const modal = createModal("title", "customId");
modal.createTextInput({label:"label", customId:"customId", style:"Short"});
modal.createTextInput({label:"label2", customId:"customId2", style:"Paragraph", placeholder:"Enter here:", required: true});
modal.show(bot, Interaction);

Here is create component and send message:

import { createComponent } from "https://deno.land/x/discord_tools@v1.0.8/mod.ts";

const component = createComponent();
component.createActionRow()
.createButton({style: "Primary", customId:"customId", "label": "label"})
.createButton({style: "Link", url:"https://www.google.com", "label": "label"});

component.sendMessage(bot, "channelId");
component.sendMessage(bot, "channelId",{content:"content"}); // or send with options

Also can edit message, send interaction or edit interaction:

const component = createComponent();
component.createActionRow()
.createSelectMenu({customId:"customId", options:[{label:"label", value:"value"}]});

component.editMessage(bot, "channelId", "messageId");
component.editMessage(bot, "channelId", "messageId", {content:"content"});
component.sendInteraction(bot, interaction);
component.sendInteraction(bot, interaction, {content:"content"});
component.editInteraction(bot, interaction);
component.editInteraction(bot, interaction, {content:"content"});

Here can clear and add new component:

const component = createComponent();
component.createActionRow()
.createButton({style: "Primary", customId:"customId", "label": "label"})
.createButton({style: "Link", url:"https://www.google.com", "label": "label"});

component.clear();

component.createActionRow()
.createSelectMenu({customId:"customId", options:[{label:"label", value:"value"}]});

MessageTools is easy tools for control send or edit message ( same createComponent features but has more features ):

import { MessageTools } from "https://deno.land/x/discord_tools@v1.0.8/mod.ts";

const messageTools = new MessageTools(bot);
messageTools.createActionRow().createButton({style: "Primary", customId:"customId", "label": "label"});
messageTools.setContent("Text");
// you can explore more feature for MessagesTools

messageTools.sendMessage("channelId");
messageTools.sendInteraction(Interaction);