@magicyan/discord 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,95 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Magicyan Discord
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Simple functions to facilitate discord bot development
|
|
4
|
+
> Also exports all [@magicyan/core](https://github.com/rinckodev/magicyan/tree/main/packages/core) functions
|
|
5
|
+
|
|
6
|
+
Install with
|
|
7
|
+
```bash
|
|
8
|
+
npm install @magicyan/discord
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Some functions summarize the way we create things with discord.js
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
// Create an action row of buttons with discord.js
|
|
15
|
+
new ActionRowBuilder<ButtonBuilder>({
|
|
16
|
+
components: [
|
|
17
|
+
new ButtonBuilder({
|
|
18
|
+
customId: "click-me-button",
|
|
19
|
+
label: "Click me", style: ButtonStyle.Success,
|
|
20
|
+
})
|
|
21
|
+
new ButtonBuilder({
|
|
22
|
+
customId: "dont-click-me-button",
|
|
23
|
+
label: "Don't click me", style: ButtonStyle.Danger,
|
|
24
|
+
})
|
|
25
|
+
]
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
// Create an action row of buttons with @magicyan/dicord
|
|
29
|
+
createRow(
|
|
30
|
+
new ButtonBuilder({
|
|
31
|
+
customId: "click-me-button", label: "Click me",
|
|
32
|
+
style: ButtonStyle.Success,
|
|
33
|
+
})
|
|
34
|
+
new ButtonBuilder({
|
|
35
|
+
customId: "dont-click-me-button", label: "Don't click me",
|
|
36
|
+
style: ButtonStyle.Danger,
|
|
37
|
+
})
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
// Add inputs to the modal with discord.js
|
|
41
|
+
new ModalBuilder({
|
|
42
|
+
customId: "my-modal",
|
|
43
|
+
title: "Modal Title",
|
|
44
|
+
components: [
|
|
45
|
+
new ActionRowBuilder<TextInputBuilder>({components: [
|
|
46
|
+
new TextInputBuilder({
|
|
47
|
+
customId: "name-input",
|
|
48
|
+
label: "Name",
|
|
49
|
+
placeholder: "Enter your name",
|
|
50
|
+
style: TextInputStyle.Short,
|
|
51
|
+
required: true
|
|
52
|
+
}),
|
|
53
|
+
new TextInputBuilder({
|
|
54
|
+
customId: "nio-modal",
|
|
55
|
+
label: "Bio",
|
|
56
|
+
placeholder: "Enter your bio",
|
|
57
|
+
style: TextInputStyle.Paragraph,
|
|
58
|
+
required: true
|
|
59
|
+
})
|
|
60
|
+
]})
|
|
61
|
+
]
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
// Add inputs to the modal with @magicyan/dicord
|
|
65
|
+
new ModalBuilder({
|
|
66
|
+
customId: "my-modal", title: "Modal Title",
|
|
67
|
+
components: [
|
|
68
|
+
createModalInput({
|
|
69
|
+
customId: "name-input", placeholder: "Enter your name",
|
|
70
|
+
label: "Name", style: TextInputStyle.Short, required: true
|
|
71
|
+
}),
|
|
72
|
+
createModalInput({
|
|
73
|
+
customId: "nio-modal", placeholder: "Enter your bio",
|
|
74
|
+
label: "Bio", style: TextInputStyle.Paragraph, required: true
|
|
75
|
+
}),
|
|
76
|
+
]
|
|
77
|
+
})
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
You can create a link button quickly
|
|
81
|
+
```ts
|
|
82
|
+
const url = "https://github.com/rinckodev";
|
|
83
|
+
|
|
84
|
+
createLinkButton({ url, label: "My github" });
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
You can create an embed author easily with a User object
|
|
88
|
+
```ts
|
|
89
|
+
const { user } = interactoion
|
|
90
|
+
|
|
91
|
+
new EmbedBuilder({
|
|
92
|
+
author: createEmbedAuthor({ user }),
|
|
93
|
+
description: "My embed description"
|
|
94
|
+
})
|
|
95
|
+
```
|