mirror of
https://github.com/jaronpate/unicord.git
synced 2026-10-18 21:47:40 +00:00
Update README.md for beta release
This commit is contained in:
@@ -1,11 +1,13 @@
|
|||||||
<div align="center">
|
<div align="center">
|
||||||
<h2>discord.ts</h2>
|
<h2>discord.ts</h2>
|
||||||
<p>Build good bots fast</p>
|
<p><em>Build good bots fast</em></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
> This package is in an early beta stage and not yet ready for consumption
|
> This package is in early development and is not yet ready for production use. Please be aware that the API may change at any time. Use at your own risk.
|
||||||
|
|
||||||
A solid and simple Discord API wrapper.
|
This library is designed with three pillars in mind: **Simple**, **Maintainable**, and **Scalable**. It isn't guaranteed to be the fastest or the most feature rich, but you will probably find it to be the easiest to use and understand.
|
||||||
|
|
||||||
|
It's typecript first and has some nifty features like hydration and argument type resolution. The goal here is to not have to worry about if you are using the Gateway, Webhooks, or Application commands. Ideally there is a single API that can be used to inferface with Discord.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -125,37 +127,56 @@ client.chatCommands.register('me', async (context: Context, _args: any[]) => {
|
|||||||
|
|
||||||
Additionally you can hydrate repeatedly if you need to fetch multiple objects at different times.
|
Additionally you can hydrate repeatedly if you need to fetch multiple objects at different times.
|
||||||
|
|
||||||
<!--
|
|
||||||
## Interactions
|
## Interactions
|
||||||
|
|
||||||
First create the interactions.
|
First create the interactions.
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
bot.commands.register('test', (_client, context, _args) => {
|
client.chatCommands.register('demo', async (context: Context, _args: any[]) => {
|
||||||
// Add components to use interactions
|
const msg = new Message()
|
||||||
const msg = new Message().setContent('Test interaction!').addComponent(
|
.setContent('Hello World!')
|
||||||
// This generations an action row which can optionaly contain content
|
.addComponent(
|
||||||
'This is an action row',
|
'This is an action row',
|
||||||
// Create components with helper functions
|
// Max buttons in a row is 5
|
||||||
Message.button({
|
// Custom ID is required and must be unique
|
||||||
label: 'Click me!',
|
// Non-Link buttons can not have a URL
|
||||||
style: ComponentStyle.Primary,
|
// Link buttons can not have a custom ID
|
||||||
// Assign id's to reference them later
|
Message.button({
|
||||||
custom_id: 'click_me',
|
label: 'Click me!',
|
||||||
emoji: {
|
style: ComponentStyle.Primary,
|
||||||
name: '🔥',
|
custom_id: 'button_1'
|
||||||
id: null,
|
}),
|
||||||
animated: false
|
Message.button({
|
||||||
}
|
label: 'No me!',
|
||||||
})
|
style: ComponentStyle.Secondary,
|
||||||
);
|
custom_id: 'button_2',
|
||||||
|
disabled: true
|
||||||
|
}),
|
||||||
|
Message.button({
|
||||||
|
label: 'Never, me!',
|
||||||
|
style: ComponentStyle.Success,
|
||||||
|
custom_id: 'button_3'
|
||||||
|
}),
|
||||||
|
// Link requires url and can not have custom_id
|
||||||
|
Message.button({
|
||||||
|
label: 'Piss off.',
|
||||||
|
style: ComponentStyle.Link,
|
||||||
|
url: 'https://example.com'
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
context.reply(msg);
|
context.reply(msg);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
Then provide a handler for them.
|
Then provide a handler for them.
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
bot.interactions.register('click_me', async (client, context, interaction) => {
|
const buttonInteractionHandler = (context: Context, data: InteractionCommpoentData) => {
|
||||||
const response = context.reply(
|
context.reply(`You clicked the ${data.custom_id} button!`);
|
||||||
`You clicked me! Thank you ${interaction.member.user.username} <3`
|
};
|
||||||
);
|
|
||||||
});
|
client.interactions.register('button_1', buttonInteractionHandler);
|
||||||
|
client.interactions.register('button_2', buttonInteractionHandler);
|
||||||
|
client.interactions.register('button_3', buttonInteractionHandler);
|
||||||
```
|
```
|
||||||
-->
|
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "discord.ts",
|
"name": "discord.ts",
|
||||||
"description": "A simple discord library for TypeScript. REST like and easy to use.",
|
"description": "A simple discord library primarily for TypeScript. REST like and easy to use.",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"module": "src/index.ts",
|
"module": "src/index.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -107,6 +107,42 @@ client.chatCommands.register('here', async (context: Context, _args: any[]) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Interactions
|
// Interactions
|
||||||
|
client.chatCommands.register('demo', async (context: Context, _args: any[]) => {
|
||||||
|
const msg = new Message()
|
||||||
|
.setContent('Hello World!')
|
||||||
|
.addComponent(
|
||||||
|
'This is an action row',
|
||||||
|
// Max buttons in a row is 5
|
||||||
|
// Custom ID is required and must be unique
|
||||||
|
// Non-Link buttons can not have a URL
|
||||||
|
// Link buttons can not have a custom ID
|
||||||
|
Message.button({
|
||||||
|
label: 'Click me!',
|
||||||
|
style: ComponentStyle.Primary,
|
||||||
|
custom_id: 'button_1'
|
||||||
|
}),
|
||||||
|
Message.button({
|
||||||
|
label: 'No me!',
|
||||||
|
style: ComponentStyle.Secondary,
|
||||||
|
custom_id: 'button_2',
|
||||||
|
disabled: true
|
||||||
|
}),
|
||||||
|
Message.button({
|
||||||
|
label: 'Never, me!',
|
||||||
|
style: ComponentStyle.Success,
|
||||||
|
custom_id: 'button_3'
|
||||||
|
}),
|
||||||
|
// Link requires url and can not have custom_id
|
||||||
|
Message.button({
|
||||||
|
label: 'Piss off.',
|
||||||
|
style: ComponentStyle.Link,
|
||||||
|
url: 'https://example.com'
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
context.reply(msg);
|
||||||
|
});
|
||||||
|
|
||||||
client.chatCommands.register('demo', async (context: Context, _args: any[]) => {
|
client.chatCommands.register('demo', async (context: Context, _args: any[]) => {
|
||||||
const msg = new Message()
|
const msg = new Message()
|
||||||
.setContent('Hello World!')
|
.setContent('Hello World!')
|
||||||
|
|||||||
Reference in New Issue
Block a user