├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
└── workflows
│ └── pages.yml
├── .gitignore
├── .npmignore
├── .prettierrc.json
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── PULL_REQUEST_TEMPLATE.md
├── README.md
├── docs
├── CNAME
├── assets
│ ├── css
│ │ └── main.css
│ ├── images
│ │ ├── icons.png
│ │ ├── icons@2x.png
│ │ ├── widgets.png
│ │ └── widgets@2x.png
│ └── js
│ │ ├── main.js
│ │ └── search.js
├── classes
│ ├── applicationcommand.html
│ ├── base.html
│ ├── categorychannel.html
│ ├── channel.html
│ ├── client.html
│ ├── clientuser.html
│ ├── collection.html
│ ├── color.html
│ ├── commandinteraction.html
│ ├── groupchannel.html
│ ├── guild.html
│ ├── guildchannel.html
│ ├── member.html
│ ├── message.html
│ ├── newschannel.html
│ ├── newsthread.html
│ ├── permissionoverwrite.html
│ ├── privatechannel.html
│ ├── privatethread.html
│ ├── publicthread.html
│ ├── role.html
│ ├── stagechannel.html
│ ├── storechannel.html
│ ├── textchannel.html
│ ├── thread.html
│ ├── user.html
│ └── voicechannel.html
├── enums
│ ├── activitytypes.html
│ ├── applicationcommandoptionstypes.html
│ ├── channeltypes.html
│ ├── intents.html
│ └── permissions.html
├── index.html
├── interfaces
│ ├── activity.html
│ ├── applicationcommandbase.html
│ ├── applicationcommandoption.html
│ ├── applicationcommandoptionchoice.html
│ ├── applicationcommandoptionwithsubcommand.html
│ ├── clientoptions.html
│ ├── editapplicationcommandoptions.html
│ ├── imageurloptions.html
│ ├── messageoptions.html
│ ├── messageoptionswithcontent.html
│ └── presence.html
└── modules.html
├── package.json
├── src
├── Client.ts
├── Constants.ts
├── gateway
│ ├── Gateway.ts
│ ├── WebSocket.ts
│ └── eventHandlers
│ │ ├── EventHandler.ts
│ │ ├── READY.ts
│ │ └── index.ts
├── index.ts
├── rest
│ ├── EndPoints.ts
│ └── RestManager.ts
├── structures
│ ├── ApplicationCommand.ts
│ ├── Base.ts
│ ├── ClientUser.ts
│ ├── CommandInteraction.ts
│ ├── Guild.ts
│ ├── Member.ts
│ ├── Message.ts
│ ├── Role.ts
│ ├── User.ts
│ ├── channels
│ │ ├── CategoryChannel.ts
│ │ ├── Channel.ts
│ │ ├── GroupChannel.ts
│ │ ├── GuildChannel.ts
│ │ ├── NewsChannel.ts
│ │ ├── NewsThread.ts
│ │ ├── PrivateChannel.ts
│ │ ├── PrivateThread.ts
│ │ ├── PublicThread.ts
│ │ ├── StageChannel.ts
│ │ ├── StoreChannel.ts
│ │ ├── TextChannel.ts
│ │ ├── Thread.ts
│ │ └── VoiceChannel.ts
│ └── index.ts
└── utils
│ ├── Collection.ts
│ ├── Color.ts
│ ├── Errors.ts
│ ├── EventEmitter.ts
│ ├── Interactions.ts
│ ├── PermissionOverwrite.ts
│ ├── Permissions.ts
│ ├── Snowflake.ts
│ └── Utils.ts
├── tsconfig.json
└── typedoc.json
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: bug
6 | assignees: Arcoz0308
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **Expected behavior**
14 | A clear and concise description of what you expected to happen.
15 |
16 | **Screenshots**
17 | If applicable, add screenshots to help explain your problem.
18 |
19 | **Additional context**
20 | Add any other context about the problem here.
21 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: suggestion
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe your suggestion**
11 | A clear and concise description of your suggestion
12 |
--------------------------------------------------------------------------------
/.github/workflows/pages.yml:
--------------------------------------------------------------------------------
1 | # Simple workflow for deploying static content to GitHub Pages
2 | name: Deploy static content to Pages
3 |
4 | on:
5 | # Runs on pushes targeting the default branch
6 | push:
7 | branches: ["master"]
8 |
9 | # Allows you to run this workflow manually from the Actions tab
10 | workflow_dispatch:
11 |
12 | # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13 | permissions:
14 | contents: read
15 | pages: write
16 | id-token: write
17 |
18 | # Allow one concurrent deployment
19 | concurrency:
20 | group: "pages"
21 | cancel-in-progress: true
22 |
23 | jobs:
24 | # Single deploy job since we're just deploying
25 | deploy:
26 | environment:
27 | name: github-pages
28 | url: ${{ steps.deployment.outputs.page_url }}
29 | runs-on: ubuntu-latest
30 | steps:
31 | - name: Checkout
32 | uses: actions/checkout@v3
33 | - name: Setup Pages
34 | uses: actions/configure-pages@v2
35 | - name: Upload artifact
36 | uses: actions/upload-pages-artifact@v1
37 | with:
38 | # Upload entire repository
39 | path: '.'
40 | - name: Deploy to GitHub Pages
41 | id: deployment
42 | uses: actions/deploy-pages@v1
43 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | Test.ts
3 | lib
4 | .idea
5 | config.json
6 | docsjson
7 | package-lock.json
8 | deno/.idea
9 | deno/config.ts
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | src/
2 | tsconfig.json
3 | Test.ts
4 | docs/
5 | config.json
6 | typedoc.json
7 | node_modules
8 | deno/
9 | .github/
10 | script/
--------------------------------------------------------------------------------
/.prettierrc.json:
--------------------------------------------------------------------------------
1 | {}
2 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | We as members, contributors, and leaders pledge to make participation in our
6 | community a harassment-free experience for everyone, regardless of age, body
7 | size, visible or invisible disability, ethnicity, sex characteristics, gender
8 | identity and expression, level of experience, education, socio-economic status,
9 | nationality, personal appearance, race, religion, or sexual identity
10 | and orientation.
11 |
12 | We pledge to act and interact in ways that contribute to an open, welcoming,
13 | diverse, inclusive, and healthy community.
14 |
15 | ## Our Standards
16 |
17 | Examples of behavior that contributes to a positive environment for our
18 | community include:
19 |
20 | * Demonstrating empathy and kindness toward other people
21 | * Being respectful of differing opinions, viewpoints, and experiences
22 | * Giving and gracefully accepting constructive feedback
23 | * Accepting responsibility and apologizing to those affected by our mistakes,
24 | and learning from the experience
25 | * Focusing on what is best not just for us as individuals, but for the
26 | overall community
27 |
28 | Examples of unacceptable behavior include:
29 |
30 | * The use of sexualized language or imagery, and sexual attention or
31 | advances of any kind
32 | * Trolling, insulting or derogatory comments, and personal or political attacks
33 | * Public or private harassment
34 | * Publishing others' private information, such as a physical or email
35 | address, without their explicit permission
36 | * Other conduct which could reasonably be considered inappropriate in a
37 | professional setting
38 |
39 | ## Enforcement Responsibilities
40 |
41 | Community leaders are responsible for clarifying and enforcing our standards of
42 | acceptable behavior and will take appropriate and fair corrective action in
43 | response to any behavior that they deem inappropriate, threatening, offensive,
44 | or harmful.
45 |
46 | Community leaders have the right and responsibility to remove, edit, or reject
47 | comments, commits, code, wiki edits, issues, and other contributions that are
48 | not aligned to this Code of Conduct, and will communicate reasons for moderation
49 | decisions when appropriate.
50 |
51 | ## Scope
52 |
53 | This Code of Conduct applies within all community spaces, and also applies when
54 | an individual is officially representing the community in public spaces.
55 | Examples of representing our community include using an official e-mail address,
56 | posting via an official social media account, or acting as an appointed
57 | representative at an online or offline event.
58 |
59 | ## Enforcement
60 |
61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
62 | reported to the community leaders responsible for enforcement at
63 | .
64 | All complaints will be reviewed and investigated promptly and fairly.
65 |
66 | All community leaders are obligated to respect the privacy and security of the
67 | reporter of any incident.
68 |
69 | ## Enforcement Guidelines
70 |
71 | Community leaders will follow these Community Impact Guidelines in determining
72 | the consequences for any action they deem in violation of this Code of Conduct:
73 |
74 | ### 1. Correction
75 |
76 | **Community Impact**: Use of inappropriate language or other behavior deemed
77 | unprofessional or unwelcome in the community.
78 |
79 | **Consequence**: A private, written warning from community leaders, providing
80 | clarity around the nature of the violation and an explanation of why the
81 | behavior was inappropriate. A public apology may be requested.
82 |
83 | ### 2. Warning
84 |
85 | **Community Impact**: A violation through a single incident or series
86 | of actions.
87 |
88 | **Consequence**: A warning with consequences for continued behavior. No
89 | interaction with the people involved, including unsolicited interaction with
90 | those enforcing the Code of Conduct, for a specified period of time. This
91 | includes avoiding interactions in community spaces as well as external channels
92 | like social media. Violating these terms may lead to a temporary or
93 | permanent ban.
94 |
95 | ### 3. Temporary Ban
96 |
97 | **Community Impact**: A serious violation of community standards, including
98 | sustained inappropriate behavior.
99 |
100 | **Consequence**: A temporary ban from any sort of interaction or public
101 | communication with the community for a specified period of time. No public or
102 | private interaction with the people involved, including unsolicited interaction
103 | with those enforcing the Code of Conduct, is allowed during this period.
104 | Violating these terms may lead to a permanent ban.
105 |
106 | ### 4. Permanent Ban
107 |
108 | **Community Impact**: Demonstrating a pattern of violation of community
109 | standards, including sustained inappropriate behavior, harassment of an
110 | individual, or aggression toward or disparagement of classes of individuals.
111 |
112 | **Consequence**: A permanent ban from any sort of public interaction within
113 | the community.
114 |
115 | ## Attribution
116 |
117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118 | version 2.0, available at
119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120 |
121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct
122 | enforcement ladder](https://github.com/mozilla/diversity).
123 |
124 | [homepage]: https://www.contributor-covenant.org
125 |
126 | For answers to common questions about this code of conduct, see the FAQ at
127 | https://www.contributor-covenant.org/faq. Translations are available at
128 | https://www.contributor-covenant.org/translations.
129 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | if you want to contribute to this project please respect my own style of code, if you have suggestion for that please open a issue.
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Arcoz0308
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | - [ ] The code is tested with not any errors,
2 | - [ ] The code is tested with errors,
3 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | NO MORE EXIST, Old project
2 |
3 | new project with same name : https://github.com/Arcoz0308/arcscord
--------------------------------------------------------------------------------
/docs/CNAME:
--------------------------------------------------------------------------------
1 | arcscord.js.org
--------------------------------------------------------------------------------
/docs/assets/images/icons.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arcoz0308/arcscord_old/11b114e9c38e44f6ab36ea974cccb878e7251b6c/docs/assets/images/icons.png
--------------------------------------------------------------------------------
/docs/assets/images/icons@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arcoz0308/arcscord_old/11b114e9c38e44f6ab36ea974cccb878e7251b6c/docs/assets/images/icons@2x.png
--------------------------------------------------------------------------------
/docs/assets/images/widgets.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arcoz0308/arcscord_old/11b114e9c38e44f6ab36ea974cccb878e7251b6c/docs/assets/images/widgets.png
--------------------------------------------------------------------------------
/docs/assets/images/widgets@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arcoz0308/arcscord_old/11b114e9c38e44f6ab36ea974cccb878e7251b6c/docs/assets/images/widgets@2x.png
--------------------------------------------------------------------------------
/docs/classes/base.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Base | arcscord
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | Search
20 |
21 |
22 |
23 | Preparing search index...
24 | The search index is not available
25 |
26 |
arcscord
27 |
28 |
48 |
49 |
50 |
51 |
52 |
53 |
61 |
Class Base
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | Hierarchy
70 |
71 |
72 | Base
73 |
102 |
103 |
104 |
105 |
106 | Index
107 |
108 |
109 |
110 | Properties
111 |
114 |
115 |
116 |
117 |
118 |
119 | Properties
120 |
121 |
122 | Readonly client
123 |
124 |
129 |
130 |
131 |
132 |
157 |
158 |
159 |
160 |
161 |
Legend
162 |
163 |
164 | Constructor
165 | Property
166 | Method
167 |
168 |
169 | Inherited constructor
170 | Inherited property
171 | Inherited method
172 |
173 |
176 |
177 | Static method
178 |
179 |
180 |
181 |
182 |
183 |
Generated using TypeDoc
184 |
185 |
186 |
187 |
188 |
--------------------------------------------------------------------------------
/docs/classes/message.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Message | arcscord
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | Search
20 |
21 |
22 |
23 | Preparing search index...
24 | The search index is not available
25 |
26 |
arcscord
27 |
28 |
48 |
49 |
50 |
51 |
52 |
53 |
61 |
Class Message
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | Hierarchy
70 |
71 |
72 | Base
73 |
74 |
75 | Message
76 |
77 |
78 |
79 |
80 |
81 |
82 | Index
83 |
84 |
85 |
86 | Constructors
87 |
90 |
91 |
92 | Properties
93 |
98 |
99 |
100 |
101 |
102 |
103 | Constructors
104 |
105 |
106 | constructor
107 |
108 | new Message( client: Client , data: APIMessage ) : Message
109 |
110 |
111 |
112 |
118 | Parameters
119 |
120 |
121 |
122 |
123 |
124 | data: APIMessage
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 | Properties
134 |
135 |
136 | channelId
137 | channelId: ` ${ bigint } `
138 |
143 |
144 |
145 |
146 | Readonly client
147 |
148 |
154 |
155 |
156 |
157 | id
158 | id: ` ${ bigint } `
159 |
164 |
165 |
166 |
167 |
201 |
202 |
203 |
204 |
205 |
Legend
206 |
207 |
208 | Constructor
209 | Property
210 | Method
211 |
212 |
213 | Inherited constructor
214 | Inherited property
215 | Inherited method
216 |
217 |
220 |
221 | Static method
222 |
223 |
224 |
225 |
226 |
227 |
Generated using TypeDoc
228 |
229 |
230 |
231 |
232 |
--------------------------------------------------------------------------------
/docs/classes/newsthread.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | NewsThread | arcscord
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | Search
20 |
21 |
22 |
23 | Preparing search index...
24 | The search index is not available
25 |
26 |
arcscord
27 |
28 |
48 |
49 |
50 |
51 |
52 |
53 |
61 |
Class NewsThread
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | Hierarchy
70 |
71 |
72 | Thread
73 |
74 |
75 | NewsThread
76 |
77 |
78 |
79 |
80 |
81 |
82 | Index
83 |
84 |
85 |
86 | Properties
87 |
90 |
91 |
92 |
93 |
94 |
95 | Properties
96 |
97 |
98 | Readonly client
99 |
100 |
106 |
107 |
108 |
109 |
134 |
135 |
136 |
137 |
138 |
Legend
139 |
140 |
141 | Constructor
142 | Property
143 | Method
144 |
145 |
146 | Inherited constructor
147 | Inherited property
148 | Inherited method
149 |
150 |
153 |
154 | Static method
155 |
156 |
157 |
158 |
159 |
160 |
Generated using TypeDoc
161 |
162 |
163 |
164 |
165 |
--------------------------------------------------------------------------------
/docs/classes/privatethread.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | PrivateThread | arcscord
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | Search
20 |
21 |
22 |
23 | Preparing search index...
24 | The search index is not available
25 |
26 |
arcscord
27 |
28 |
48 |
49 |
50 |
51 |
52 |
53 |
61 |
Class PrivateThread
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | Hierarchy
70 |
71 |
72 | Thread
73 |
74 |
75 | PrivateThread
76 |
77 |
78 |
79 |
80 |
81 |
82 | Index
83 |
84 |
85 |
86 | Properties
87 |
90 |
91 |
92 |
93 |
94 |
95 | Properties
96 |
97 |
98 | Readonly client
99 |
100 |
106 |
107 |
108 |
109 |
134 |
135 |
136 |
137 |
138 |
Legend
139 |
140 |
141 | Constructor
142 | Property
143 | Method
144 |
145 |
146 | Inherited constructor
147 | Inherited property
148 | Inherited method
149 |
150 |
153 |
154 | Static method
155 |
156 |
157 |
158 |
159 |
160 |
Generated using TypeDoc
161 |
162 |
163 |
164 |
165 |
--------------------------------------------------------------------------------
/docs/classes/publicthread.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | PublicThread | arcscord
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | Search
20 |
21 |
22 |
23 | Preparing search index...
24 | The search index is not available
25 |
26 |
arcscord
27 |
28 |
48 |
49 |
50 |
51 |
52 |
53 |
61 |
Class PublicThread
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | Hierarchy
70 |
71 |
72 | Thread
73 |
74 |
75 | PublicThread
76 |
77 |
78 |
79 |
80 |
81 |
82 | Index
83 |
84 |
85 |
86 | Properties
87 |
90 |
91 |
92 |
93 |
94 |
95 | Properties
96 |
97 |
98 | Readonly client
99 |
100 |
106 |
107 |
108 |
109 |
134 |
135 |
136 |
137 |
138 |
Legend
139 |
140 |
141 | Constructor
142 | Property
143 | Method
144 |
145 |
146 | Inherited constructor
147 | Inherited property
148 | Inherited method
149 |
150 |
153 |
154 | Static method
155 |
156 |
157 |
158 |
159 |
160 |
Generated using TypeDoc
161 |
162 |
163 |
164 |
165 |
--------------------------------------------------------------------------------
/docs/classes/role.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Role | arcscord
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | Search
20 |
21 |
22 |
23 | Preparing search index...
24 | The search index is not available
25 |
26 |
arcscord
27 |
28 |
48 |
49 |
50 |
51 |
52 |
53 |
61 |
Class Role
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | Hierarchy
70 |
71 |
72 | Base
73 |
78 |
79 |
80 |
81 |
82 | Index
83 |
84 |
85 |
86 | Properties
87 |
90 |
91 |
92 |
93 |
94 |
95 | Properties
96 |
97 |
98 | Readonly client
99 |
100 |
106 |
107 |
108 |
109 |
134 |
135 |
136 |
137 |
138 |
Legend
139 |
140 |
141 | Constructor
142 | Property
143 | Method
144 |
145 |
146 | Inherited constructor
147 | Inherited property
148 | Inherited method
149 |
150 |
153 |
154 | Static method
155 |
156 |
157 |
158 |
159 |
160 |
Generated using TypeDoc
161 |
162 |
163 |
164 |
165 |
--------------------------------------------------------------------------------
/docs/classes/thread.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Thread | arcscord
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | Search
20 |
21 |
22 |
23 | Preparing search index...
24 | The search index is not available
25 |
26 |
arcscord
27 |
28 |
48 |
49 |
50 |
51 |
52 |
53 |
61 |
Class Thread
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | Hierarchy
70 |
71 |
72 | Base
73 |
74 |
75 | Thread
76 |
87 |
88 |
89 |
90 |
91 |
92 |
93 | Index
94 |
95 |
96 |
97 | Properties
98 |
101 |
102 |
103 |
104 |
105 |
106 | Properties
107 |
108 |
109 | Readonly client
110 |
111 |
117 |
118 |
119 |
120 |
145 |
146 |
147 |
148 |
149 |
Legend
150 |
151 |
152 | Constructor
153 | Property
154 | Method
155 |
156 |
157 | Inherited constructor
158 | Inherited property
159 | Inherited method
160 |
161 |
164 |
165 | Static method
166 |
167 |
168 |
169 |
170 |
171 |
Generated using TypeDoc
172 |
173 |
174 |
175 |
176 |
--------------------------------------------------------------------------------
/docs/enums/activitytypes.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ActivityTypes | arcscord
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | Search
20 |
21 |
22 |
23 | Preparing search index...
24 | The search index is not available
25 |
26 |
arcscord
27 |
28 |
48 |
49 |
50 |
51 |
52 |
53 |
61 |
Enumeration ActivityTypes
62 |
63 |
64 |
65 |
66 |
67 |
68 |
75 |
76 | Index
77 |
78 |
79 |
80 | Enumeration members
81 |
89 |
90 |
91 |
92 |
93 |
94 | Enumeration members
95 |
96 |
97 | competing
98 | competing: = 5
99 |
104 |
109 |
110 |
111 |
112 | custom
113 | custom: = 4
114 |
119 |
125 |
126 |
127 |
128 | game
129 | game: = 0
130 |
135 |
140 |
141 |
142 |
143 | listening
144 | listening: = 2
145 |
150 |
155 |
156 |
157 |
158 | streaming
159 | streaming: = 1
160 |
165 |
170 |
171 |
172 |
173 | watching
174 | watching: = 3
175 |
180 |
185 |
186 |
187 |
188 |
228 |
229 |
230 |
231 |
232 |
Legend
233 |
234 |
235 | Constructor
236 | Property
237 | Method
238 |
239 |
240 | Inherited constructor
241 | Inherited property
242 | Inherited method
243 |
244 |
247 |
248 | Static method
249 |
250 |
251 |
252 |
253 |
254 |
Generated using TypeDoc
255 |
256 |
257 |
258 |
259 |
--------------------------------------------------------------------------------
/docs/interfaces/activity.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Activity | arcscord
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | Search
20 |
21 |
22 |
23 | Preparing search index...
24 | The search index is not available
25 |
26 |
arcscord
27 |
28 |
48 |
49 |
50 |
51 |
52 |
53 |
61 |
Interface Activity
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | Hierarchy
70 |
71 |
72 | Activity
73 |
74 |
75 |
76 |
77 | Index
78 |
79 |
80 |
81 | Properties
82 |
87 |
88 |
89 |
90 |
91 |
92 | Properties
93 |
94 |
95 | name
96 | name: string
97 |
102 |
107 |
108 |
109 |
110 | Optional type
111 | type: "game" | "streaming" | "listening" | "watching" | "custom" | "competing"
112 |
117 |
130 |
131 |
132 |
133 | Optional url
134 | url: string
135 |
140 |
145 |
146 |
147 |
148 |
179 |
180 |
181 |
182 |
183 |
Legend
184 |
185 |
186 | Constructor
187 | Property
188 | Method
189 |
190 |
191 | Inherited constructor
192 | Inherited property
193 | Inherited method
194 |
195 |
198 |
199 | Static method
200 |
201 |
202 |
203 |
204 |
205 |
Generated using TypeDoc
206 |
207 |
208 |
209 |
210 |
--------------------------------------------------------------------------------
/docs/interfaces/applicationcommandbase.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ApplicationCommandBase | arcscord
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | Search
20 |
21 |
22 |
23 | Preparing search index...
24 | The search index is not available
25 |
26 |
arcscord
27 |
28 |
48 |
49 |
50 |
51 |
52 |
53 |
61 |
Interface ApplicationCommandBase
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | Hierarchy
70 |
71 |
72 | ApplicationCommandBase
73 |
74 |
75 |
76 |
77 | Index
78 |
79 |
80 |
81 | Properties
82 |
88 |
89 |
90 |
91 |
92 |
93 | Properties
94 |
95 |
96 | defaultPermissions
97 | defaultPermissions: boolean
98 |
103 |
108 |
109 |
110 |
111 | description
112 | description: string
113 |
118 |
123 |
124 |
125 |
126 | name
127 | name: string
128 |
133 |
138 |
139 |
140 |
141 | options
142 |
143 |
148 |
153 |
154 |
155 |
156 |
190 |
191 |
192 |
193 |
194 |
Legend
195 |
196 |
197 | Constructor
198 | Property
199 | Method
200 |
201 |
202 | Inherited constructor
203 | Inherited property
204 | Inherited method
205 |
206 |
209 |
210 | Static method
211 |
212 |
213 |
214 |
215 |
216 |
Generated using TypeDoc
217 |
218 |
219 |
220 |
221 |
--------------------------------------------------------------------------------
/docs/interfaces/applicationcommandoption.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ApplicationCommandOption | arcscord
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | Search
20 |
21 |
22 |
23 | Preparing search index...
24 | The search index is not available
25 |
26 |
arcscord
27 |
28 |
48 |
49 |
50 |
51 |
52 |
53 |
61 |
Interface ApplicationCommandOption
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | Hierarchy
70 |
71 |
72 | ApplicationCommandOption
73 |
78 |
79 |
80 |
81 |
82 | Index
83 |
84 |
85 |
86 | Properties
87 |
94 |
95 |
96 |
97 |
98 |
99 | Properties
100 |
101 |
102 | Optional choices
103 |
104 |
109 |
114 |
115 |
116 |
117 | description
118 | description: string
119 |
124 |
129 |
130 |
131 |
132 | name
133 | name: string
134 |
139 |
144 |
145 |
146 |
147 | required
148 | required: boolean
149 |
154 |
164 |
165 |
166 |
167 | type
168 | type: "string" | "boolean" | "subCommand" | "subCommandGroup" | "integer" | "user" | "channel" | "role" | "mentionable"
169 |
174 |
179 |
180 |
181 |
182 |
219 |
220 |
221 |
222 |
223 |
Legend
224 |
225 |
226 | Constructor
227 | Property
228 | Method
229 |
230 |
231 | Inherited constructor
232 | Inherited property
233 | Inherited method
234 |
235 |
238 |
239 | Static method
240 |
241 |
242 |
243 |
244 |
245 |
Generated using TypeDoc
246 |
247 |
248 |
249 |
250 |
--------------------------------------------------------------------------------
/docs/interfaces/applicationcommandoptionchoice.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ApplicationCommandOptionChoice | arcscord
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | Search
20 |
21 |
22 |
23 | Preparing search index...
24 | The search index is not available
25 |
26 |
arcscord
27 |
28 |
48 |
49 |
50 |
51 |
52 |
53 |
61 |
Interface ApplicationCommandOptionChoice
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | Hierarchy
70 |
71 |
72 | ApplicationCommandOptionChoice
73 |
74 |
75 |
76 |
77 | Index
78 |
79 |
80 |
81 | Properties
82 |
86 |
87 |
88 |
89 |
90 |
91 | Properties
92 |
93 |
94 | name
95 | name: string
96 |
101 |
106 |
107 |
108 |
109 | value
110 | value: string | number
111 |
116 |
121 |
122 |
123 |
124 |
152 |
153 |
154 |
155 |
156 |
Legend
157 |
158 |
159 | Constructor
160 | Property
161 | Method
162 |
163 |
164 | Inherited constructor
165 | Inherited property
166 | Inherited method
167 |
168 |
171 |
172 | Static method
173 |
174 |
175 |
176 |
177 |
178 |
Generated using TypeDoc
179 |
180 |
181 |
182 |
183 |
--------------------------------------------------------------------------------
/docs/interfaces/editapplicationcommandoptions.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | EditApplicationCommandOptions | arcscord
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | Search
20 |
21 |
22 |
23 | Preparing search index...
24 | The search index is not available
25 |
26 |
arcscord
27 |
28 |
48 |
49 |
50 |
51 |
52 |
53 |
61 |
Interface EditApplicationCommandOptions
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | Hierarchy
70 |
71 |
72 | EditApplicationCommandOptions
73 |
74 |
75 |
76 |
77 | Index
78 |
79 |
80 |
81 | Properties
82 |
88 |
89 |
90 |
91 |
92 |
93 | Properties
94 |
95 |
96 | Optional defaultPermissions
97 | defaultPermissions: boolean
98 |
103 |
108 |
109 |
110 |
111 | Optional description
112 | description: string
113 |
118 |
123 |
124 |
125 |
126 | Optional name
127 | name: string
128 |
133 |
138 |
139 |
140 |
141 | Optional options
142 |
143 |
148 |
153 |
154 |
155 |
156 |
190 |
191 |
192 |
193 |
194 |
Legend
195 |
196 |
197 | Constructor
198 | Property
199 | Method
200 |
201 |
202 | Inherited constructor
203 | Inherited property
204 | Inherited method
205 |
206 |
209 |
210 | Static method
211 |
212 |
213 |
214 |
215 |
216 |
Generated using TypeDoc
217 |
218 |
219 |
220 |
221 |
--------------------------------------------------------------------------------
/docs/interfaces/imageurloptions.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ImageUrlOptions | arcscord
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | Search
20 |
21 |
22 |
23 | Preparing search index...
24 | The search index is not available
25 |
26 |
arcscord
27 |
28 |
48 |
49 |
50 |
51 |
52 |
53 |
61 |
Interface ImageUrlOptions
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | Hierarchy
70 |
71 |
72 | ImageUrlOptions
73 |
74 |
75 |
76 |
77 | Index
78 |
79 |
80 |
81 | Properties
82 |
87 |
88 |
89 |
90 |
91 |
92 | Properties
93 |
94 |
95 | Optional dynamic
96 | dynamic: boolean
97 |
102 |
112 |
113 |
114 |
115 | Optional format
116 |
117 |
122 |
132 |
133 |
134 |
135 | Optional size
136 |
137 |
142 |
152 |
153 |
154 |
155 |
186 |
187 |
188 |
189 |
190 |
Legend
191 |
192 |
193 | Constructor
194 | Property
195 | Method
196 |
197 |
198 | Inherited constructor
199 | Inherited property
200 | Inherited method
201 |
202 |
205 |
206 | Static method
207 |
208 |
209 |
210 |
211 |
212 |
Generated using TypeDoc
213 |
214 |
215 |
216 |
217 |
--------------------------------------------------------------------------------
/docs/interfaces/messageoptions.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | MessageOptions | arcscord
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | Search
20 |
21 |
22 |
23 | Preparing search index...
24 | The search index is not available
25 |
26 |
arcscord
27 |
28 |
48 |
49 |
50 |
51 |
52 |
53 |
61 |
Interface MessageOptions
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | Hierarchy
70 |
71 |
72 | MessageOptions
73 |
78 |
79 |
80 |
81 |
82 |
102 |
103 |
104 |
105 |
106 |
Legend
107 |
108 |
109 | Constructor
110 | Property
111 | Method
112 |
113 |
114 | Inherited constructor
115 | Inherited property
116 | Inherited method
117 |
118 |
121 |
122 | Static method
123 |
124 |
125 |
126 |
127 |
128 |
Generated using TypeDoc
129 |
130 |
131 |
132 |
133 |
--------------------------------------------------------------------------------
/docs/interfaces/messageoptionswithcontent.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | MessageOptionsWithContent | arcscord
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | Search
20 |
21 |
22 |
23 | Preparing search index...
24 | The search index is not available
25 |
26 |
arcscord
27 |
28 |
48 |
49 |
50 |
51 |
52 |
53 |
61 |
Interface MessageOptionsWithContent
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | Hierarchy
70 |
71 |
72 | MessageOptions
73 |
74 |
75 | MessageOptionsWithContent
76 |
77 |
78 |
79 |
80 |
81 |
82 | Index
83 |
84 |
85 |
86 | Properties
87 |
90 |
91 |
92 |
93 |
94 |
95 | Properties
96 |
97 |
98 | Optional content
99 | content: string
100 |
105 |
106 |
107 |
108 |
133 |
134 |
135 |
136 |
137 |
Legend
138 |
139 |
140 | Constructor
141 | Property
142 | Method
143 |
144 |
145 | Inherited constructor
146 | Inherited property
147 | Inherited method
148 |
149 |
152 |
153 | Static method
154 |
155 |
156 |
157 |
158 |
159 |
Generated using TypeDoc
160 |
161 |
162 |
163 |
164 |
--------------------------------------------------------------------------------
/docs/interfaces/presence.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Presence | arcscord
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | Search
20 |
21 |
22 |
23 | Preparing search index...
24 | The search index is not available
25 |
26 |
arcscord
27 |
28 |
48 |
49 |
50 |
51 |
52 |
53 |
61 |
Interface Presence
62 |
63 |
64 |
65 |
66 |
67 |
68 |
79 |
80 | Hierarchy
81 |
82 |
83 | Presence
84 |
85 |
86 |
87 |
88 | Index
89 |
90 |
91 |
92 | Properties
93 |
98 |
99 |
100 |
101 |
102 |
103 | Properties
104 |
105 |
106 | Optional activity
107 |
108 |
113 |
119 |
120 |
121 |
122 | Optional afk
123 | afk: boolean
124 |
129 |
134 |
135 |
136 |
137 | Optional status
138 |
139 |
144 |
150 |
151 |
152 |
153 |
184 |
185 |
186 |
187 |
188 |
Legend
189 |
190 |
191 | Constructor
192 | Property
193 | Method
194 |
195 |
196 | Inherited constructor
197 | Inherited property
198 | Inherited method
199 |
200 |
203 |
204 | Static method
205 |
206 |
207 |
208 |
209 |
210 |
Generated using TypeDoc
211 |
212 |
213 |
214 |
215 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "arcscord",
3 | "version": "0.3.1-beta",
4 | "description": "A library to interact with the Discord API written in typescript",
5 | "main": "lib/index.js",
6 | "types": "lib/index.d.ts",
7 | "files": [
8 | "lib/"
9 | ],
10 | "scripts": {
11 | "test": "ts-node Test.ts",
12 | "build": "tsc",
13 | "docs": "typedoc --tsconfig typedoc.json",
14 | "deno": "node script/deno"
15 | },
16 | "author": "arcoz0308",
17 | "license": "MIT",
18 | "dependencies": {
19 | "@types/node": "^15.0.1",
20 | "@types/ws": "^7.4.2",
21 | "axios": "^0.21.1",
22 | "discord-api-types": "^0.37.4",
23 | "ws": "^7.4.5"
24 | },
25 | "devDependencies": {
26 | "i": "^0.3.6",
27 | "npm": "^8.18.0",
28 | "prettier": "2.3.0",
29 | "ts-node": "^9.1.1",
30 | "typedoc": "^0.20.37",
31 | "typedoc-light-theme": "^1.1.0",
32 | "typedoc-plugin-as-member-of": "^1.0.2",
33 | "typedoc-plugin-cname": "^1.0.1",
34 | "typescript": "^4.2.4"
35 | },
36 | "keywords": [
37 | "discord",
38 | "typescript",
39 | "api"
40 | ],
41 | "directories": {
42 | "lib": "lib"
43 | },
44 | "repository": {
45 | "type": "git",
46 | "url": "git+https://github.com/arcoz0308/arcscord.git"
47 | },
48 | "bugs": {
49 | "url": "https://github.com/arcoz0308/arcscord/issues"
50 | },
51 | "homepage": "https://github.com/arcoz0308/arcscord#readme"
52 | }
53 |
--------------------------------------------------------------------------------
/src/Constants.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * list of intents
3 | * @see https://discord.com/developers/docs/topics/gateway#list-of-intents
4 | */
5 |
6 | export enum Intents {
7 | /**
8 | * include events :
9 | * - GUILD_CREATE
10 | * - GUILD_UPDATE
11 | * - GUILD_DELETE
12 | * - GUILD_ROLE_CREATE
13 | * - GUILD_ROLE_UPDATE
14 | * - GUILD_ROLE_DELETE
15 | * - CHANNEL_CREATE
16 | * - CHANNEL_UPDATE
17 | * - CHANNEL_DELETE
18 | * - CHANNEL_PINS_UPDATE
19 | * - THREAD_CREATE
20 | * - THREAD_UPDATE
21 | * - THREAD_DELETE
22 | * - THREAD_LIST_SYNC
23 | * - THREAD_MEMBER_UPDATE
24 | * - THREAD_MEMBERS_UPDATE
25 | */
26 | GUILDS = 1 << 0,
27 | /**
28 | * include events :
29 | * - GUILD_MEMBER_ADD
30 | * - GUILD_MEMBER_UPDATE
31 | * - GUILD_MEMBER_REMOVE
32 | * - THREAD_MEMBERS_UPDATE
33 | */
34 | GUILD_MEMBERS = 1 << 1,
35 | /**
36 | * include events :
37 | * - GUILD_BAN_ADD
38 | * - GUILD_BAN_REMOVE
39 | */
40 | GUILD_BANS = 1 << 2,
41 | /**
42 | * include event :
43 | * GUILD_EMOJIS_UPDATE
44 | */
45 | GUILD_EMOJIS = 1 << 3,
46 | /**
47 | * include events :
48 | * - GUILD_INTEGRATIONS_UPDATE
49 | * - INTEGRATION_CREATE
50 | * - INTEGRATION_UPDATE
51 | * - INTEGRATION_DELETE
52 | */
53 | GUILD_INTEGRATIONS = 1 << 4,
54 | /**
55 | * include event :
56 | * - WEBHOOKS_UPDATE
57 | */
58 | GUILD_WEBHOOKS = 1 << 5,
59 | /**
60 | * include events
61 | * - INVITE_CREATE
62 | * - INVITE_DELETE
63 | */
64 | GUILD_INVITES = 1 << 6,
65 | /**
66 | * include event :
67 | * - VOICE_STATE_UPDATE
68 | */
69 | GUILD_VOICE_STATES = 1 << 7,
70 | /**
71 | * include event :
72 | * - PRESENCE_UPDATE
73 | */
74 | GUILD_PRESENCES = 1 << 8,
75 | /**
76 | * include events
77 | * - MESSAGE_CREATE
78 | * - MESSAGE_UPDATE
79 | * - MESSAGE_DELETE
80 | * - MESSAGE_DELETE_BULK
81 | */
82 | GUILD_MESSAGES = 1 << 9,
83 | /**
84 | * include events :
85 | * - MESSAGE_REACTION_ADD
86 | * - MESSAGE_REACTION_REMOVE
87 | * - MESSAGE_REACTION_REMOVE_ALL
88 | * - MESSAGE_REACTION_REMOVE_EMOJI
89 | */
90 | GUILD_MESSAGE_REACTIONS = 1 << 10,
91 | /**
92 | * include event :
93 | * - TYPING_START
94 | */
95 | GUILD_MESSAGE_TYPING = 1 << 11,
96 | /**
97 | * include events :
98 | * - MESSAGE_CREATE
99 | * - MESSAGE_UPDATE
100 | * - MESSAGE_DELETE
101 | * - CHANNEL_PINS_UPDATE
102 | */
103 | DIRECT_MESSAGES = 1 << 12,
104 | /**
105 | * include events :
106 | * - MESSAGE_REACTION_ADD
107 | * - MESSAGE_REACTION_REMOVE
108 | * - MESSAGE_REACTION_REMOVE_ALL
109 | * - MESSAGE_REACTION_REMOVE_EMOJI
110 | */
111 | DIRECT_MESSAGE_REACTIONS = 1 << 13,
112 | /**
113 | * include event :
114 | * - TYPING_START
115 | */
116 | DIRECT_MESSAGE_TYPING = 1 << 14,
117 |
118 | /**
119 | * You need to use this intent if you want get content of message, WARNING : priviliged intent for verified bots
120 | */
121 | MESSAGE_CONTENT = 1 << 15,
122 |
123 | /**
124 | * include events :
125 | * GUILD_SCHEDULED_EVENT_CREATE
126 | * - GUILD_SCHEDULED_EVENT_UPDATE
127 | * - GUILD_SCHEDULED_EVENT_DELETE
128 | * - GUILD_SCHEDULED_EVENT_USER_ADD
129 | * - GUILD_SCHEDULED_EVENT_USER_REMOVE
130 | */
131 | GUILD_SCHEDULED_EVENTS = 1 << 16,
132 |
133 | /**
134 | * include events :
135 | * - AUTO_MODERATION_RULE_CREATE
136 | * - AUTO_MODERATION_RULE_UPDATE
137 | * - AUTO_MODERATION_RULE_DELETE
138 | */
139 | AUTO_MODERATION_CONFIGURATION = 1 << 20,
140 |
141 | /**
142 | * include event :
143 | * - AUTO_MODERATION_ACTION_EXECUTION
144 | */
145 | AUTO_MODERATION_EXECUTION = 1 << 21,
146 |
147 | /**
148 | * include all intents
149 | */
150 | ALL = GUILDS | GUILD_MEMBERS | GUILD_BANS | GUILD_EMOJIS | GUILD_INTEGRATIONS | GUILD_WEBHOOKS | GUILD_INVITES | GUILD_VOICE_STATES | GUILD_PRESENCES | GUILD_MESSAGES |
151 | GUILD_MESSAGE_REACTIONS | GUILD_MESSAGE_TYPING | DIRECT_MESSAGES | DIRECT_MESSAGE_REACTIONS | DIRECT_MESSAGE_TYPING | MESSAGE_CONTENT | GUILD_SCHEDULED_EVENTS |
152 | AUTO_MODERATION_CONFIGURATION | AUTO_MODERATION_EXECUTION
153 | }
154 |
155 | export type IntentMode = 'add' | 'remove';
156 |
157 | export interface IntentOptions {
158 | /**
159 | * if si add mode, you add each intent from 0, and with remove system, you start with all and remove with you chose
160 | * @default 'add'
161 | */
162 | mode?: IntentMode;
163 |
164 | /**
165 | * list of intent that you add/remove
166 | */
167 | intents?: Intents[];
168 | }
169 |
170 | export const API_VERSION: number = 10;
171 |
--------------------------------------------------------------------------------
/src/gateway/WebSocket.ts:
--------------------------------------------------------------------------------
1 | import * as Ws from 'ws';
2 | import { EventEmitter } from '../utils/EventEmitter';
3 |
4 |
5 | export class AWebSocket extends EventEmitter<{
6 | open: () => void;
7 | close: (code: number, reason: string) => void;
8 | message: (message: string) => void;
9 | ping: (body: Buffer) => void;
10 | pong: (body: Buffer) => void;
11 | error: (error: Error) => void;
12 | }> {
13 | private _ws: Ws;
14 | constructor(endpoint: string | URL) {
15 | super();
16 | this._ws = new Ws(endpoint);
17 | this._ws.on('open', () => this.emit('open'));
18 | this._ws.on('close', (code, reason) => this.emit('close', code, reason));
19 | this._ws.on('message', (data) => this.emit('message', data as string));
20 | this._ws.on('ping', (data) => this.emit('ping', data));
21 | this._ws.on('pong', (data) => this.emit('pong', data));
22 | this._ws.on('error', (error) => this.emit('error', error));
23 | }
24 |
25 | send(message: string) {
26 | this._ws.send(message);
27 | }
28 |
29 | close(code?: number, reason?: string) {
30 | this._ws.close(code, reason);
31 | }
32 |
33 | get isOpen(): boolean {
34 | return this._ws.readyState === Ws.OPEN;
35 | }
36 |
37 | get isClosed(): boolean {
38 | return this._ws.readyState === Ws.CLOSED || this._ws.readyState === Ws.CLOSING;
39 | }
40 |
41 | get readyState(): 0 | 1 | 2 | 3 {
42 | return this._ws.readyState;
43 | }
44 | }
--------------------------------------------------------------------------------
/src/gateway/eventHandlers/EventHandler.ts:
--------------------------------------------------------------------------------
1 | import { Client } from '../../Client';
2 |
3 |
4 | export class EventHandler {
5 | public client: Client;
6 |
7 | constructor(client: Client) {
8 | this.client = client;
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/gateway/eventHandlers/READY.ts:
--------------------------------------------------------------------------------
1 | import { GatewayReadyDispatchData } from 'discord-api-types/v10';
2 | import { ClientUser } from '../../structures';
3 | import { Snowflake } from '../../utils/Snowflake';
4 | import { EventHandler } from './EventHandler';
5 |
6 |
7 | export class READY extends EventHandler {
8 | async handle(d: GatewayReadyDispatchData) {
9 | this.client.user = new ClientUser(this.client, d.user);
10 | this.client.users.set(d.user.id as Snowflake, this.client.user);
11 | for (const guild of d.guilds) {
12 | await this.client.fetchGuild(guild.id as Snowflake);
13 | }
14 | if (this.client.fetchAllMembers) {
15 | for (const [id] of this.client.guilds) {
16 | await this.client.fetchMembers(id, 1000);
17 | }
18 | }
19 | if (this.client.slashCommand) {
20 | const commands = await this.client.fetchApplicationCommands();
21 | if (commands) {
22 | for (const command of commands) {
23 | this.client.slashCommands.set(command.id, command);
24 | }
25 | }
26 | }
27 | this.client.emit('ready');
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/gateway/eventHandlers/index.ts:
--------------------------------------------------------------------------------
1 | export * from './READY';
2 |
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './Client';
2 | export * from './Constants';
3 | export * from './structures';
4 | export * from './utils/Collection';
5 | export * from './utils/Color';
6 | export * from './utils/PermissionOverwrite';
7 | export * from './utils/Permissions';
8 | export * from './utils/Snowflake';
9 | export * from './utils/Utils';
10 |
--------------------------------------------------------------------------------
/src/rest/EndPoints.ts:
--------------------------------------------------------------------------------
1 | import { Snowflake } from '../utils/Snowflake';
2 | import { imageFormats, imageSize } from '../utils/Utils';
3 |
4 |
5 | export const REST_VERSION = 10;
6 | export const BASE_URL = `https://discord.com/api/v${REST_VERSION}`;
7 | export const IMAGE_BASE_URL = 'https://cdn.discordapp.com';
8 | // @formatter:off
9 | export const APPLICATION_GLOBAL_COMMAND = (applicationId: Snowflake, cmdId: Snowflake) => `/applications/${applicationId}/commands/${cmdId}`;
10 | export const APPLICATION_GLOBAL_COMMANDS = (applicationId: Snowflake) => `/applications/${applicationId}/commands`;
11 | export const APPLICATION_GUILD_COMMAND = (applicationId: Snowflake, guildId: Snowflake, cmdId: Snowflake) => `/applications/${applicationId}/guilds/${guildId}/commands/${cmdId}`;
12 | export const APPLICATION_GUILD_COMMANDS = (applicationId: Snowflake, guildId: Snowflake) => `/applications/${applicationId}/guilds/${guildId}/commands`;
13 | export const DM_CHANNEL = '/users/@me/channels';
14 | export const GATEWAY_CONNECT = '/gateway/bot';
15 | export const GUILD = (guildId: Snowflake) => `/guilds/${guildId}`;
16 | export const GUILD_MEMBERS = (guildId: Snowflake, limit: number, after: number) => `/guilds/${guildId}/members?limit=${limit}&after=${after}`;
17 | export const MESSAGE = (channelId: Snowflake, msgId: Snowflake) => `/channels/${channelId}/messages/${msgId}`;
18 | export const MESSAGES = (channelId: Snowflake) => `/channels/${channelId}/messages`;
19 | export const USER_ME = '/users/@me';
20 |
21 |
22 | //images
23 | export const DEFAULT_USER_AVATAR = (discriminator: string) => `/${IMAGE_BASE_URL}/embed/avatars/${discriminator}.png`;
24 | export const USER_AVATAR = (user: string, hash: string, format: imageFormats, size: imageSize) => `/${IMAGE_BASE_URL}/avatars/${user}/${hash}.${format}?size${size}`;
25 | // @formatter:on
--------------------------------------------------------------------------------
/src/rest/RestManager.ts:
--------------------------------------------------------------------------------
1 | import axios from 'axios';
2 | import { Client } from '../Client';
3 | import { RequestError } from '../utils/Errors';
4 | import { BASE_URL } from './EndPoints';
5 |
6 |
7 | export type Method =
8 | | 'get' | 'GET'
9 | | 'delete' | 'DELETE'
10 | | 'head' | 'HEAD'
11 | | 'options' | 'OPTIONS'
12 | | 'post' | 'POST'
13 | | 'put' | 'PUT'
14 | | 'patch' | 'PATCH'
15 | | 'purge' | 'PURGE'
16 | | 'link' | 'LINK'
17 | | 'unlink' | 'UNLINK';
18 | export interface rawRest {
19 | method: Method;
20 | url: string;
21 | data?: any;
22 | response: {
23 | status: number;
24 | data: any;
25 | }
26 |
27 | }
28 | export class RestManager {
29 | private token: string;
30 |
31 | constructor(client: Client) {
32 | this.token = client.token.startsWith('Bot ') ?
33 | client.token :
34 | 'Bot ' + client.token;
35 | }
36 | request(method: Method, url: string, data?: object): Promise {
37 | return new Promise(async (resolve, reject) => {
38 | const response = await axios({
39 | method: method,
40 | baseURL: BASE_URL,
41 | url: url,
42 | data: data,
43 | headers: {
44 | Authorization: this.token
45 | },
46 | timeout: 1000
47 | }).catch(e => {
48 | console.log(e);
49 | return reject(new RequestError('API ERROR', method, url, data, e.response?.data?.code, e.response?.data?.message));
50 | });
51 | if (response) resolve(response.data);
52 | else reject('UNKNOWN ERROR');
53 | });
54 | }
55 | }
--------------------------------------------------------------------------------
/src/structures/ApplicationCommand.ts:
--------------------------------------------------------------------------------
1 | import { Client } from '../Client';
2 | import { Snowflake } from '../utils/Snowflake';
3 | import { Base } from './Base';
4 | import { Guild } from './Guild';
5 |
6 |
7 | export interface ApplicationCommandBase {
8 | /**
9 | * the name of the command
10 | */
11 | name: string;
12 | /**
13 | * the description of the command
14 | */
15 | description: string;
16 | /**
17 | * the options of the command
18 | */
19 | options: Array;
20 | /**
21 | * if the command are enable when the app is add to a guild
22 | */
23 | defaultPermissions: boolean;
24 | }
25 |
26 | export interface EditApplicationCommandOptions {
27 | /**
28 | * the name of the command
29 | */
30 | name?: string;
31 | /**
32 | * the description of the command
33 | */
34 | description?: string;
35 | /**
36 | * the options of the command
37 | */
38 | options?: Array;
39 | /**
40 | * if the command are enable when the app is add to a guild
41 | */
42 | defaultPermissions?: boolean;
43 | }
44 |
45 | export interface ApplicationCommandOption {
46 | /**
47 | * the type of the command option
48 | */
49 | type: ApplicationCommandOptionsType;
50 | /**
51 | * name of the command option (1 to 32 characters that match `^[\w-]{1,32}$`)
52 | */
53 | name: string;
54 | /**
55 | * description of the command option (1 to 100 characters)
56 | */
57 | description: string;
58 | /**
59 | * if the option is required
60 | * @default false
61 | */
62 | required: boolean;
63 |
64 | /**
65 | * choices of the command option,You can specify a maximum of 25 choices per option
66 | */
67 | choices?: ApplicationCommandOptionChoice[];
68 | }
69 |
70 | export interface ApplicationCommandOptionWithSubCommand extends ApplicationCommandOption {
71 | /**
72 | * options of command subCommand/subCommandGroup
73 | */
74 | options?: ApplicationCommandOptionWithSubCommand;
75 | }
76 |
77 | export enum ApplicationCommandOptionsTypes {
78 | subCommand = 1,
79 | subCommandGroup,
80 | string,
81 | integer,
82 | boolean,
83 | user,
84 | channel,
85 | role,
86 | mentionable
87 | }
88 |
89 | export interface ApplicationCommandOptionChoice {
90 | /**
91 | * the name of the choice
92 | */
93 | name: string;
94 | /**
95 | * the value of the choice
96 | */
97 | value: string | number;
98 | }
99 |
100 | export type ApplicationCommandOptionsType = keyof typeof ApplicationCommandOptionsTypes;
101 |
102 | export class ApplicationCommand extends Base {
103 | updateData(cmd: any) {
104 | throw new Error('Method not implemented.');
105 | }
106 |
107 | /**
108 | * the id of the command
109 | */
110 | public id!: Snowflake;
111 |
112 | /**
113 | * the guild of the command (is null for global commands)
114 | */
115 | public guild!: Guild | null;
116 |
117 | /**
118 | * the name of the command
119 | */
120 | public name!: string;
121 |
122 | /**
123 | * the description of the command
124 | */
125 | public description!: string;
126 |
127 | /**
128 | * the options of the command
129 | */
130 | public options!: ApplicationCommandOption[] | null;
131 |
132 | /**
133 | * if the command is enable by default on add guild
134 | */
135 | public defaultPermission!: boolean;
136 | /**
137 | * @internal
138 | */
139 | public data: { [index: string]: any };
140 |
141 | constructor(client: Client, data: {[index: string]: any}) {
142 | super(client);
143 | this.id = data.id;
144 | this.guild = data['guild_id'] ? client.guilds.get(data['guild_id']) || null : null;
145 | this.name = data.name;
146 | this.description = data.description;
147 | this.options = data.options ? data.options as unknown as ApplicationCommandOption[] : null;
148 | this.defaultPermission = typeof data.default_permission !== 'undefined' ? data.default_permission : true;
149 | this.data = data;
150 | }
151 |
152 | public edit(data: EditApplicationCommandOptions, cache = true): Promise {
153 | return this.client.editApplicationCommand(this.id, data, cache);
154 | }
155 |
156 | public toString(): string {
157 | return `${this.name} : ${this.description}`;
158 | }
159 |
160 | public toJSON(space = 1): string {
161 | return JSON.stringify({
162 | id: this.id,
163 | application_id: this.client.user?.id || undefined,
164 | guild_id: this.guild ? this.guild.id : undefined,
165 | name: this.name,
166 | description: this.description,
167 | options: this.options || undefined,
168 | default_permission: this.defaultPermission
169 | }, null, space);
170 | }
171 |
172 | _patchData(data: { [index: string]: any }) {
173 | this.id = data.id;
174 | this.guild = data['guild_id'] ? this.client.guilds.get(data['guild_id']) || null : null;
175 | this.name = data.name;
176 | this.description = data.description;
177 | this.options = data.options ? data.options as unknown as ApplicationCommandOption[] : null;
178 | this.defaultPermission = typeof data.default_permission !== 'undefined' ? data.default_permission : true;
179 | this.data = data;
180 | };
181 | }
182 |
183 | /**
184 | * @internal
185 | */
186 | export function resolveApplicationCommandForApi(cmd: {[index: string]: any}): object {
187 | if (cmd.hasOwnProperty('options')) cmd['options'] = resolveApplicationCommandOptionsForApi([cmd['options']]);
188 | return cmd;
189 | }
190 |
191 | /**
192 | * @internal
193 | */
194 | function resolveApplicationCommandOptionsForApi(options: {[index: string]: any}[]): object[] {
195 | const newOptions = [];
196 | for (let option of options) {
197 | if (option['options']) option['options'] = resolveApplicationCommandOptionsForApi(option['options']);
198 | option['type'] = ApplicationCommandOptionsTypes[option['type']];
199 | newOptions.push(option);
200 | }
201 | return newOptions;
202 | }
--------------------------------------------------------------------------------
/src/structures/Base.ts:
--------------------------------------------------------------------------------
1 | import { Client } from '../Client';
2 |
3 |
4 | /**
5 | * @category Structures
6 | */
7 | export abstract class Base {
8 | public readonly client: Client;
9 |
10 | protected constructor(client: Client) {
11 | this.client = client;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/structures/ClientUser.ts:
--------------------------------------------------------------------------------
1 | import { USER_ME } from '../rest/EndPoints';
2 | import { Activity, Presence, PresenceStatus } from './';
3 | import { User } from './User';
4 |
5 |
6 | /**
7 | * @category Structures
8 | */
9 | export class ClientUser extends User {
10 | /**
11 | * get current presence of the bot
12 | */
13 | get presence(): Presence | null {
14 | if (this.client.presence) return this.client.presence;
15 | return null;
16 | }
17 |
18 | /**
19 | * update bot presence
20 | * @param presence a object of presence
21 | *
22 | * @example
23 | * client.user.setPresence({
24 | * status: "dnd",
25 | * activity: {
26 | * type: "game",
27 | * name: "on arcscord"
28 | * }
29 | * });
30 | */
31 | public setPresence(presence: Presence) {
32 | if (!presence.status) presence.status = this.client.presence.status;
33 | if (!presence.status) presence.status = 'online';
34 | this.client.presence = presence;
35 | this.client.gateway.updatePresence(presence);
36 | }
37 |
38 | /**
39 | * update the status of the ClientUser
40 | * @param status the status to set
41 | * @example
42 | * client.user.setStatus('dnd');
43 | */
44 | public setStatus(status: PresenceStatus) {
45 | this.client.presence.status = status;
46 | this.client.gateway.updatePresence(this.client.presence);
47 | }
48 |
49 | /**
50 | * update the activity of the ClientUser
51 | * @param activity the activity to set
52 | * @example
53 | * client.user.setActivity({
54 | * name: 'using arcscord',
55 | * type: 'game'
56 | * });
57 | */
58 | public setActivity(activity: Activity) {
59 | this.client.presence.activity = activity;
60 | this.client.gateway.updatePresence(this.client.presence);
61 | }
62 |
63 | public edit(data: { username?: string; avatar?: string }) {
64 | this.client.requestHandler
65 | .request('PATCH', USER_ME, data)
66 | .then((r) => {
67 | this.username = r.username;
68 | this.avatar = r.avatar;
69 | })
70 | .catch(console.error);
71 | }
72 |
73 | public setUsername(username: string) {
74 | this.edit({ username });
75 | }
76 |
77 | public setAvatar(avatar: string) {
78 | //TODO check data format
79 | this.edit({ avatar });
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/src/structures/CommandInteraction.ts:
--------------------------------------------------------------------------------
1 | import { APIInteraction, Utils } from 'discord-api-types/v10';
2 | import { Client } from '../Client';
3 | import { Snowflake } from '../utils/Snowflake';
4 | import { Base } from './Base';
5 | import { Channel } from './channels/Channel';
6 | import { Guild } from './Guild';
7 | import { Member } from './Member';
8 | import { User } from './User';
9 |
10 |
11 | /**
12 | * @category Structures
13 | */
14 | export class CommandInteraction extends Base {
15 | public id!: Snowflake;
16 | public channel!: Channel | null;
17 | public guild!: Guild | null;
18 | public user!: User | null;
19 | public member!: Member | null;
20 | public token!: string;
21 | public data!: APIInteraction;
22 |
23 | constructor(client: Client, data: APIInteraction) {
24 | super(client);
25 | this._patchData(data);
26 | }
27 |
28 | _patchData(data: APIInteraction) {
29 | this.data = data;
30 | this.id = data.id as Snowflake;
31 | this.channel = this.client.channels.get(data.channel_id as Snowflake) || null;
32 | this.token = data.token;
33 | if (Utils.isGuildInteraction(data)) {
34 | this.guild = this.client.guilds.get(data.guild_id as Snowflake)!;
35 | this.member =
36 | this.guild.members.get(data.member.user.id as Snowflake) ||
37 | new Member(this.client, this.guild, data.member);
38 | this.user = this.member.user;
39 | } else {
40 | this.guild = null;
41 | this.member = null;
42 | this.user = data.user ? this.client.users.get(data.user.id as Snowflake) || new User(this.client, data.user) : null;
43 | }
44 | }
45 | }
46 |
47 | /*
48 | TODO finish this
49 | export async function resolveInteractionCmdUserOption(option: ApplicationCommandOption): User|null {
50 | if (option.type !== 'user') return null;
51 |
52 |
53 | }
54 |
55 | */
56 |
--------------------------------------------------------------------------------
/src/structures/Guild.ts:
--------------------------------------------------------------------------------
1 | import { APIGuild } from 'discord-api-types/v10';
2 | import { Client } from '../Client';
3 | import { Collection } from '../utils/Collection';
4 | import { Snowflake } from '../utils/Snowflake';
5 | import { ApplicationCommand } from './ApplicationCommand';
6 | import { Base } from './Base';
7 | import { Channel, ChannelTypes } from './channels/Channel';
8 | import { VoiceChannel } from './channels/VoiceChannel';
9 | import { Member } from './Member';
10 | import { User } from './User';
11 |
12 |
13 | /**
14 | * @category Structures
15 | */
16 | export class Guild extends Base {
17 | public id!: Snowflake;
18 | public name!: string;
19 | public icon!: string | null;
20 | public slash!: string | null;
21 | public discoverySlash!: string | null;
22 | public ownerId!: Snowflake;
23 | public owner!: User;
24 | public afkChannelId!: Snowflake | null;
25 | public channels = new Collection();
26 | public members = new Collection();
27 | public slashCommands = new Collection();
28 |
29 | public data!: APIGuild;
30 |
31 | constructor(client: Client, data: APIGuild) {
32 | super(client);
33 | this._patchData(data);
34 | }
35 |
36 | get afkChannel(): VoiceChannel | null {
37 | return this.afkChannelId && this.channels.has(this.afkChannelId) ?
38 | this.channels.get(this.afkChannelId)!.type === ChannelTypes.VOICE_CHANNEL ? this.channels.get(this.afkChannelId) as VoiceChannel : null
39 | : null;
40 | }
41 |
42 | /**
43 | * get all applications commands of this guild
44 | * @param [cache=true] set the commands to cache
45 | * @return a array of commands object
46 | */
47 | public fetchApplicationCommands(cache = true): Promise {
48 | return this.client.fetchGuildApplicationCommands(this.id, cache);
49 | }
50 |
51 | _patchData(data: APIGuild) {
52 | this.id = data.id as Snowflake;
53 | this.name = data.name;
54 | this.icon = data.icon;
55 | this.slash = data.splash;
56 | this.discoverySlash = data.discovery_splash;
57 | this.ownerId = data.owner_id as Snowflake;
58 | this.owner = this.client.users.get(data.owner_id as Snowflake)!;
59 | this.afkChannelId = data.afk_channel_id as Snowflake;
60 |
61 | this.data = data;
62 | }
63 | }
64 |
65 |
--------------------------------------------------------------------------------
/src/structures/Member.ts:
--------------------------------------------------------------------------------
1 | import { APIGuildMember } from 'discord-api-types/v10';
2 | import { Client } from '../Client';
3 | import { Snowflake } from '../utils/Snowflake';
4 | import { Base } from './Base';
5 | import { Guild } from './Guild';
6 | import { User } from './User';
7 |
8 |
9 | /**
10 | * @category Structures
11 | */
12 | export class Member extends Base {
13 | public user!: User;
14 | public nick!: string | null;
15 | public roles!: Snowflake[];
16 | public joinedAt!: string;
17 | public premiumSince!: string | null;
18 | public deaf!: boolean;
19 | public mute!: boolean;
20 | public guild!: Guild;
21 |
22 | constructor(client: Client, guild: Guild, data: APIGuildMember) {
23 | super(client);
24 | this._patchData(data);
25 | this.guild = guild;
26 | }
27 |
28 | toString(): string {
29 | return `<@${this.nick ? '!' : ''}${this.user?.id}>`;
30 | }
31 |
32 | _patchData(data: APIGuildMember) {
33 | this.user =
34 | this.client.users.get(data.user?.id as Snowflake) ||
35 | new User(this.client, data.user!);
36 | this.nick = typeof data.nick !== 'undefined' ? data.nick : null;
37 | this.roles = data.roles as Snowflake[];
38 | this.joinedAt = data.joined_at;
39 | this.premiumSince =
40 | typeof data.premium_since !== 'undefined' ? data.premium_since : null;
41 | this.deaf = data.deaf;
42 | this.mute = data.mute;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/structures/Message.ts:
--------------------------------------------------------------------------------
1 | import { APIMessage } from 'discord-api-types/v10';
2 | import { Client } from '../Client';
3 | import { Snowflake } from '../utils/Snowflake';
4 | import { Base } from './Base';
5 |
6 |
7 | /**
8 | * @category Structures
9 | */
10 | export class Message extends Base {
11 |
12 | public id!: Snowflake;
13 | public channelId!: Snowflake;
14 |
15 | constructor(client: Client, data: APIMessage) {
16 | super(client);
17 | this._patchData(data);
18 | }
19 |
20 | _patchData(data: APIMessage) {
21 | this.id = data.id as Snowflake;
22 | this.channelId = data.channel_id as Snowflake;
23 | }
24 | }
25 |
26 | export interface MessageOptions {
27 | }
28 |
29 | export interface MessageOptionsWithContent extends MessageOptions {
30 | content?: string;
31 | }
32 |
--------------------------------------------------------------------------------
/src/structures/Role.ts:
--------------------------------------------------------------------------------
1 | import { Base } from './Base';
2 |
3 |
4 | export class Role extends Base {
5 |
6 | }
--------------------------------------------------------------------------------
/src/structures/User.ts:
--------------------------------------------------------------------------------
1 | import { APIUser } from 'discord-api-types/v10';
2 | import { Client } from '../Client';
3 | import { DEFAULT_USER_AVATAR, USER_AVATAR } from '../rest/EndPoints';
4 | import { getDate, Snowflake } from '../utils/Snowflake';
5 | import { ImageUrlOptions } from '../utils/Utils';
6 | import { Base } from './Base';
7 |
8 |
9 | /**
10 | * @category Structures
11 | */
12 | export class User extends Base {
13 | /**
14 | * the id of the user
15 | */
16 | public id!: Snowflake;
17 |
18 | /**
19 | * hash of user avatar
20 | */
21 | public avatar!: string | null;
22 |
23 | /**
24 | * username of the user
25 | */
26 | public username!: string;
27 |
28 | /**
29 | * discriminator of the user
30 | */
31 | public discriminator!: string;
32 |
33 | /**
34 | * tag of the user (username#descriminator)
35 | */
36 | public tag!: string;
37 |
38 | /**
39 | * if the user is a bot
40 | */
41 | public bot!: boolean;
42 |
43 | /**
44 | * if the user are a official discord system user
45 | */
46 | public system!: boolean;
47 |
48 | /**
49 | * the date of the user account was created in timestamp
50 | */
51 | public createAt!: number;
52 |
53 | /**
54 | * user public's flags
55 | */
56 | public publicFlags!: number;
57 |
58 | /**
59 | *
60 | * @param client
61 | * @param data
62 | */
63 | constructor(client: Client, data: APIUser) {
64 | super(client);
65 |
66 | // init data
67 | this._patchData(data);
68 | }
69 |
70 | /**
71 | * get avatar URL
72 | * @param format the format of image
73 | * @param size the size of image
74 | * @param dynamic if the avatar are animated give gif
75 | */
76 | avatarURL({ format, size, dynamic }: ImageUrlOptions): string {
77 | if (!format) format = 'jpg';
78 | if (!size) size = 4096;
79 | if (!dynamic) dynamic = false;
80 | if (!this.avatar)
81 | return DEFAULT_USER_AVATAR(`${parseInt(this.discriminator, 10) % 5}`);
82 | if (dynamic && this.avatar && this.avatar.startsWith('a_')) format = 'gif';
83 | return USER_AVATAR(this.id, this.avatar, format, size);
84 | }
85 |
86 | toString() {
87 | return `<@${this.id}>`;
88 | }
89 |
90 | toJSON(space = 1): string {
91 | return JSON.stringify({
92 | id: this.id,
93 | username: this.username,
94 | discriminator: this.discriminator,
95 | avatar: this.avatar,
96 | bot: this.bot,
97 | system: this.system,
98 | createAt: this.createAt,
99 | public_flags: this.publicFlags
100 | }, null, space);
101 | }
102 |
103 | _patchData(data: APIUser) {
104 | this.id = data.id as Snowflake;
105 | this.avatar = data.avatar;
106 | this.username = data.username;
107 | this.discriminator = data.discriminator;
108 | this.tag = `${data.username}#${data.discriminator}`;
109 | this.bot = !!data.bot;
110 | this.system = !!data.system;
111 | this.createAt = getDate(data.id as Snowflake);
112 | this.publicFlags = data.public_flags ? data.public_flags : 0;
113 | }
114 | }
115 |
116 | /**
117 | * list of activity types
118 | */
119 | export enum ActivityTypes {
120 | /**
121 | * Playing {game}
122 | */
123 | game = 0,
124 | /**
125 | * Streaming {details}
126 | */
127 | streaming = 1,
128 | /**
129 | * Listening to {name}
130 | */
131 | listening = 2,
132 | /**
133 | * Watching {details}
134 | */
135 | watching = 3,
136 | /**
137 | * {emoji} {details}
138 | * WARNING : don't work for bots
139 | */
140 | custom = 4,
141 | /**
142 | * Competing in {name}
143 | */
144 | competing = 5,
145 | }
146 |
147 | export type ActivityType = keyof typeof ActivityTypes;
148 |
149 | /**
150 | * a presence object
151 | * @interface
152 | */
153 | export interface Presence {
154 | /**
155 | * The user's activities
156 | *
157 | * See https://discord.com/developers/docs/topics/gateway#activity-object
158 | */
159 | activity?: Activity;
160 | /**
161 | * The user's new status
162 | *
163 | * See https://discord.com/developers/docs/topics/gateway#update-status-status-types
164 | */
165 | status?: PresenceStatus;
166 | /**
167 | * Whether or not the client is afk. default false
168 | */
169 | afk?: boolean;
170 | }
171 |
172 | export type PresenceStatus =
173 | | 'online'
174 | | 'dnd'
175 | | 'idle'
176 | | 'invisible'
177 | | 'offline';
178 |
179 | /**
180 | *
181 | */
182 | export interface Activity {
183 | /**
184 | * The activity's name
185 | */
186 | name: string;
187 | /**
188 | * Activity type
189 | *
190 | * @see https://discord.com/developers/docs/topics/gateway#activity-object-activity-types
191 | * @default "game"
192 | */
193 | type?: ActivityType;
194 | /**
195 | * Stream url (only with type Streaming)
196 | */
197 | url?: string;
198 | }
199 |
--------------------------------------------------------------------------------
/src/structures/channels/CategoryChannel.ts:
--------------------------------------------------------------------------------
1 | import { ChannelTypes } from './Channel';
2 | import { GuildChannel } from './GuildChannel';
3 |
4 |
5 | export class CategoryChannel extends GuildChannel {
6 | public readonly type = ChannelTypes.CATEGORY_CHANNEL;
7 | }
8 |
--------------------------------------------------------------------------------
/src/structures/channels/Channel.ts:
--------------------------------------------------------------------------------
1 | import { APIChannel} from 'discord-api-types/v10';
2 | import { Client } from '../../Client';
3 | import { Snowflake } from '../../utils/Snowflake';
4 | import { Base } from '../Base';
5 |
6 |
7 | export class Channel extends Base {
8 | public id: Snowflake;
9 | public readonly type: ChannelTypes;
10 |
11 | constructor(client: Client, data: APIChannel) {
12 | super(client);
13 | this.id = data.id as Snowflake;
14 | this.type = data.type as unknown as ChannelTypes;
15 | }
16 |
17 | get mention(): string {
18 | return `<#${this.id}>`;
19 | }
20 | }
21 |
22 | export enum ChannelTypes {
23 | TEXT_CHANNEL,
24 | DM_CHANNEL,
25 | VOICE_CHANNEL,
26 | GROUP_CHANNEL,
27 | CATEGORY_CHANNEL,
28 | NEWS_CHANNEL,
29 | STORE_CHANNEL,
30 | UNKNOWN,
31 | STAGE_CHANNEL = 13,
32 | }
--------------------------------------------------------------------------------
/src/structures/channels/GroupChannel.ts:
--------------------------------------------------------------------------------
1 | import { APIChannel } from 'discord-api-types/v10';
2 | import { Client } from '../../Client';
3 | import { Channel, ChannelTypes } from './Channel';
4 |
5 |
6 | export class GroupChannel extends Channel {
7 | public readonly type = ChannelTypes.GROUP_CHANNEL;
8 |
9 | constructor(client: Client, data: APIChannel) {
10 | super(client, data);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/structures/channels/GuildChannel.ts:
--------------------------------------------------------------------------------
1 | import { APIGuildChannel } from 'discord-api-types/v10';
2 | import { Client } from '../../Client';
3 | import { PermissionOverwrite } from '../../utils/PermissionOverwrite';
4 | import { Snowflake } from '../../utils/Snowflake';
5 | import { Guild } from '../Guild';
6 | import { Channel } from './Channel';
7 |
8 |
9 | export class GuildChannel extends Channel {
10 | public name: string;
11 | public guild: Guild;
12 | public nsfw: boolean;
13 | public position: number;
14 | public parentId: Snowflake | null;
15 | public permissionOverwrites: PermissionOverwrite[] = [];
16 |
17 | constructor(client: Client, data: APIGuildChannel) {
18 | super(client, data);
19 | this.guild = client.guilds.get(data.guild_id as Snowflake)!;
20 | this.name = data.name!;
21 | this.nsfw = !!data.nsfw;
22 | this.position = data.position || 0;
23 | this.parentId = data.parent_id as Snowflake || null;
24 | if (data.permission_overwrites) {
25 | for (const permissionOverwrite of data.permission_overwrites) {
26 | this.permissionOverwrites.push(
27 | new PermissionOverwrite(permissionOverwrite as {
28 | id: Snowflake;
29 | type: number;
30 | allow: string;
31 | deny: string;
32 | })
33 | );
34 | }
35 | }
36 | }
37 |
38 | update(data: APIGuildChannel): GuildChannel {
39 | if (data.name !== this.name) this.name = data.name!;
40 | if (data.nsfw !== this.nsfw) this.nsfw = !!data.nsfw;
41 | if (data.position && this.position !== data.position)
42 | this.position = data.position;
43 | if (data.parent_id && this.parentId !== data.parent_id)
44 | this.parentId = data.parent_id as Snowflake;
45 | this.permissionOverwrites = [];
46 | if (data.permission_overwrites) {
47 | for (const permissionOverwrite of data.permission_overwrites) {
48 | this.permissionOverwrites.push(
49 | new PermissionOverwrite(permissionOverwrite as {
50 | id: Snowflake;
51 | type: number;
52 | allow: string;
53 | deny: string;
54 | })
55 | );
56 | }
57 | }
58 | return this;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/structures/channels/NewsChannel.ts:
--------------------------------------------------------------------------------
1 | import { ChannelTypes } from './Channel';
2 | import { TextChannel } from './TextChannel';
3 |
4 |
5 | export class NewsChannel extends TextChannel {
6 | public rateLimitPerUser = null; // news channel don't have message rate limit
7 | public readonly type = ChannelTypes.NEWS_CHANNEL;
8 | }
9 |
--------------------------------------------------------------------------------
/src/structures/channels/NewsThread.ts:
--------------------------------------------------------------------------------
1 | import { Thread } from './Thread';
2 |
3 |
4 | export class NewsThread extends Thread {
5 | }
6 |
--------------------------------------------------------------------------------
/src/structures/channels/PrivateChannel.ts:
--------------------------------------------------------------------------------
1 | import { Channel } from './Channel';
2 |
3 |
4 | export class PrivateChannel extends Channel {
5 | }
6 |
--------------------------------------------------------------------------------
/src/structures/channels/PrivateThread.ts:
--------------------------------------------------------------------------------
1 | import { Thread } from './Thread';
2 |
3 |
4 | export class PrivateThread extends Thread {
5 | }
6 |
--------------------------------------------------------------------------------
/src/structures/channels/PublicThread.ts:
--------------------------------------------------------------------------------
1 | import { Thread } from './Thread';
2 |
3 |
4 | export class PublicThread extends Thread {
5 | }
6 |
--------------------------------------------------------------------------------
/src/structures/channels/StageChannel.ts:
--------------------------------------------------------------------------------
1 | import { ChannelTypes } from './Channel';
2 | import { VoiceChannel } from './VoiceChannel';
3 |
4 |
5 | export class StageChannel extends VoiceChannel {
6 | public readonly type = ChannelTypes.STAGE_CHANNEL;
7 | }
8 |
--------------------------------------------------------------------------------
/src/structures/channels/StoreChannel.ts:
--------------------------------------------------------------------------------
1 | import { ChannelTypes } from './Channel';
2 | import { GuildChannel } from './GuildChannel';
3 |
4 |
5 | export class StoreChannel extends GuildChannel {
6 | public readonly type = ChannelTypes.STORE_CHANNEL;
7 | }
8 |
--------------------------------------------------------------------------------
/src/structures/channels/TextChannel.ts:
--------------------------------------------------------------------------------
1 | import { APITextChannel } from 'discord-api-types/v10';
2 | import { Client } from '../../Client';
3 | import { Snowflake } from '../../utils/Snowflake';
4 | import { Message, MessageOptions, MessageOptionsWithContent } from '../Message';
5 | import { ChannelTypes } from './Channel';
6 | import { GuildChannel } from './GuildChannel';
7 |
8 |
9 | export class TextChannel extends GuildChannel {
10 | public readonly type:
11 | | ChannelTypes.TEXT_CHANNEL
12 | | ChannelTypes.NEWS_CHANNEL
13 | | ChannelTypes.UNKNOWN = ChannelTypes.TEXT_CHANNEL;
14 | public topic: string | null;
15 | public rateLimitPerUser: number | null;
16 | public lastMessageId: Snowflake | null;
17 |
18 | constructor(client: Client, data: APITextChannel) {
19 | super(client, data);
20 | this.topic = data.topic || null;
21 | this.rateLimitPerUser = data.rate_limit_per_user || null;
22 | this.lastMessageId = data.last_message_id as Snowflake || null;
23 | }
24 |
25 | update(data: APITextChannel): GuildChannel {
26 | this.lastMessageId = data.last_message_id as Snowflake || null;
27 | this.topic = data.topic || null;
28 | this.rateLimitPerUser = data.rate_limit_per_user || null;
29 | return super.update(data);
30 | }
31 |
32 | public createMessage(content: string, msg?: MessageOptions): Promise;
33 | public createMessage(msg: MessageOptionsWithContent): Promise;
34 | public async createMessage(
35 | cOrM: string | MessageOptionsWithContent,
36 | msg?: MessageOptions
37 | ): Promise {
38 | if (typeof cOrM === 'string')
39 | return this.client.createMessage(this.id, cOrM, msg);
40 | return this.client.createMessage(this.id, cOrM);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/structures/channels/Thread.ts:
--------------------------------------------------------------------------------
1 | import { Base } from '../Base';
2 |
3 |
4 | export class Thread extends Base {
5 | }
6 |
--------------------------------------------------------------------------------
/src/structures/channels/VoiceChannel.ts:
--------------------------------------------------------------------------------
1 | import { APIVoiceChannelBase } from 'discord-api-types/v10';
2 | import { Client } from '../../Client';
3 | import { ChannelTypes } from './Channel';
4 | import { GuildChannel } from './GuildChannel';
5 |
6 |
7 | export class VoiceChannel extends GuildChannel {
8 | public readonly type:
9 | | ChannelTypes.VOICE_CHANNEL
10 | | ChannelTypes.STAGE_CHANNEL
11 | | ChannelTypes.UNKNOWN;
12 |
13 | constructor(client: Client, data: APIVoiceChannelBase) {
14 | super(client, data);
15 | this.type =
16 | (data.type as unknown as ChannelTypes) === ChannelTypes.VOICE_CHANNEL
17 | ? ChannelTypes.VOICE_CHANNEL
18 | : ChannelTypes.UNKNOWN;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/structures/index.ts:
--------------------------------------------------------------------------------
1 | export * from './channels/Channel';
2 | export * from './channels/CategoryChannel';
3 | export * from './channels/GroupChannel';
4 | export * from './channels/GuildChannel';
5 | export * from './channels/NewsChannel';
6 | export * from './channels/NewsThread';
7 | export * from './channels/PrivateChannel';
8 | export * from './channels/PrivateThread';
9 | export * from './channels/PublicThread';
10 | export * from './channels/StageChannel';
11 | export * from './channels/StoreChannel';
12 | export * from './channels/TextChannel';
13 | export * from './channels/Thread';
14 | export * from './channels/VoiceChannel';
15 | export * from './ApplicationCommand';
16 | export * from './Base';
17 | export * from './ClientUser';
18 | export * from './CommandInteraction';
19 | export * from './Guild';
20 | export * from './Member';
21 | export * from './Message';
22 | export * from './Role';
23 | export * from './User';
--------------------------------------------------------------------------------
/src/utils/Collection.ts:
--------------------------------------------------------------------------------
1 | export class Collection extends Map {
2 | /**
3 | *
4 | * @param [limit=0] limit of size of the collection, 0 = no limit
5 | * @param entries
6 | */
7 | public limit: number;
8 |
9 | constructor(limit = 0, entries?: [K, V][] | null) {
10 | super(entries);
11 | this.limit = limit;
12 | }
13 |
14 | public set(key: K, value: V): any {
15 | if (this.limit !== 0 && this.size === this.limit && !this.has(key)) {
16 | this.delete(this.keys().next().value);
17 | }
18 | return super.set(key, value);
19 | }
20 |
21 | /**
22 | * find a value in the collection
23 | * @param cb the callback for find the value
24 | * @example ```ts
25 | * client.guilds.find(guild => guild.name === 'cool name');
26 | *
27 | */
28 | public find(cb: (value: V, key: K) => boolean) {
29 | for (const [key, value] of this) {
30 | if (cb(value, key)) return value;
31 | }
32 | }
33 |
34 | public filter(cb: (value: V, key: K) => boolean) {
35 | const results = new Collection(this.limit);
36 | for (const [key, value] of this) {
37 | if (cb(value, key)) results.set(key, value);
38 | }
39 | return results;
40 | }
41 |
42 | public toObject(): {[index: string]: any} {
43 | const object: {[index: string]: any} = {};
44 | this.forEach((value, key) => {
45 | object[typeof key === 'string' ? key : (typeof key === 'number' ? key.toString(10) : `invalidKey:${key}`)] = value;
46 | });
47 | return object;
48 | }
49 |
50 | public toJSON(space = 1): string {
51 | const object= this.toObject();
52 | for (const key in object) {
53 | if (object.hasOwnProperty(key) && typeof object[key] === 'object' && object[key].hasOwnProperty('toJSON')) object[key] = JSON.parse(object[key].toJSON());
54 | }
55 | return JSON.stringify(object, null, space);
56 | }
57 | }
--------------------------------------------------------------------------------
/src/utils/Color.ts:
--------------------------------------------------------------------------------
1 | export type RGB = [number, number, number];
2 |
3 | export class Color {
4 | static decimalToHex(color: number): string {
5 | return '#' + color.toString(16);
6 | }
7 |
8 | static hexToDecimal(color: string): number {
9 | if (color.includes('#')) color = color.replace('#', '');
10 | return parseInt(color, 16);
11 | }
12 |
13 | static decimalToRGB(color: number): RGB {
14 | return [(color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff];
15 | }
16 |
17 | static RGBtoDecimal(color: RGB): number {
18 | return (color[0] << 16) + (color[1] << 8) + color[2];
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/utils/Errors.ts:
--------------------------------------------------------------------------------
1 | export class RequestError extends Error {
2 | public method: string;
3 | public url: string;
4 | public data?: any;
5 | public status?: string;
6 | public msg?: string;
7 |
8 | constructor(
9 | message: string,
10 | method: string,
11 | url: string,
12 | data?: any,
13 | status?: string,
14 | msg?: string
15 | ) {
16 | message += `
17 | debug:
18 | url : ${url}
19 | data : ${data}
20 | status : ${status}
21 | message : ${msg}`;
22 | super(message);
23 | this.method = method;
24 | this.url = url;
25 | this.data = data;
26 | this.status = status;
27 | this.msg = msg;
28 | }
29 | }
30 |
31 | export class InvalidTokenError extends Error {
32 | constructor(message: string = 'Your token are invalid !') {
33 | super(message);
34 | }
35 | }
36 |
37 | export class GatewayAlreadyConnectedError extends Error {
38 | constructor(message: string = 'the bot is already connected !') {
39 | super(message);
40 | }
41 | }
--------------------------------------------------------------------------------
/src/utils/EventEmitter.ts:
--------------------------------------------------------------------------------
1 | // code from https://deno.land/x/eventemitter@1.2.1/mod.ts
2 | /** The callback type. */
3 | type Callback = (...args: any[]) => any | Promise;
4 |
5 | /** A listener type. */
6 | type Listener = Callback & { __once__?: true; };
7 |
8 | /** The name of an event. */
9 | type EventName = string | number;
10 |
11 | type EventsType =
12 | & { [key: string]: Callback; }
13 | & { [key: number]: Callback; }
14 | ;
15 |
16 | /**
17 | * The event emitter.
18 | */
19 | export class EventEmitter {
20 |
21 | /**
22 | * This is where the events and listeners are stored.
23 | */
24 | private _events_: Map> = new Map();
25 |
26 | /**
27 | * Listen for a typed event.
28 | * @param event The typed event name to listen for.
29 | * @param listener The typed listener function.
30 | */
31 | public on(event: K, listener: E[K]): this;
32 |
33 | /**
34 | * Listen for an event.
35 | * @param event The event name to listen for.
36 | * @param listener The listener function.
37 | */
38 | public on(event: EventName, listener: Callback): this {
39 | if (!this._events_.has(event)) this._events_.set(event, new Set());
40 | this._events_.get(event)!.add(listener);
41 | return this;
42 | }
43 |
44 | /**
45 | * Listen for a typed event once.
46 | * @param event The typed event name to listen for.
47 | * @param listener The typed listener function.
48 | */
49 | public once(event: K, listener: E[K]): this;
50 |
51 | /**
52 | * Listen for an event once.
53 | * @param event The event name to listen for.
54 | * @param listener The listener function.
55 | */
56 | public once(event: EventName, listener: Callback): this {
57 | const l: Listener = listener;
58 | l.__once__ = true;
59 | return this.on(event, l as any);
60 | }
61 |
62 | /**
63 | * Remove a specific listener in the event emitter on a specific
64 | * typed event.
65 | * @param event The typed event name.
66 | * @param listener The typed event listener function.
67 | */
68 | public off(event: K, listener: E[K]): this;
69 |
70 | /**
71 | * Remove all listeners on a specific typed event.
72 | * @param event The typed event name.
73 | */
74 | public off(event: K): this;
75 |
76 | /**
77 | * Remove all events from the event listener.
78 | */
79 | public off(): this;
80 |
81 | /**
82 | * Remove a specific listener on a specific event if both `event`
83 | * and `listener` is defined, or remove all listeners on a
84 | * specific event if only `event` is defined, or lastly remove
85 | * all listeners on every event if `event` is not defined.
86 | * @param event The event name.
87 | * @param listener The event listener function.
88 | */
89 | public off(event?: EventName, listener?: Callback): this {
90 | if (!event && listener)
91 | throw new Error('Why is there a listener defined here?');
92 | else if (!event && !listener)
93 | this._events_.clear();
94 | else if (event && !listener)
95 | this._events_.delete(event);
96 | else if (event && listener && this._events_.has(event)) {
97 | const _ = this._events_.get(event)!;
98 | _.delete(listener);
99 | if (_.size === 0) this._events_.delete(event);
100 | } else {
101 | throw new Error('Unknown action!');
102 | }
103 | return this;
104 | }
105 |
106 | /**
107 | * Emit a typed event without waiting for each listener to
108 | * return.
109 | * @param event The typed event name to emit.
110 | * @param args The arguments to pass to the typed listeners.
111 | */
112 | public emitSync(event: K, ...args: Parameters): this;
113 |
114 | /**
115 | * Emit an event without waiting for each listener to return.
116 | * @param event The event name to emit.
117 | * @param args The arguments to pass to the listeners.
118 | */
119 | public emitSync(event: EventName, ...args: Parameters): this {
120 | if (!this._events_.has(event)) return this;
121 | const _ = this._events_.get(event)!;
122 | for (let [, listener] of _.entries()) {
123 | const r = listener(...args);
124 | if (r instanceof Promise) r.catch(console.error);
125 | if (listener.__once__) {
126 | delete listener.__once__;
127 | _.delete(listener);
128 | }
129 | }
130 | if (_.size === 0) this._events_.delete(event);
131 | return this;
132 | }
133 |
134 | /**
135 | * Emit a typed event and wait for each typed listener to return.
136 | * @param event The typed event name to emit.
137 | * @param args The arguments to pass to the typed listeners.
138 | */
139 | public async emit(event: K, ...args: Parameters): Promise;
140 |
141 | /**
142 | * Emit an event and wait for each listener to return.
143 | * @param event The event name to emit.
144 | * @param args The arguments to pass to the listeners.
145 | */
146 | public async emit(event: EventName, ...args: Parameters): Promise {
147 | if (!this._events_.has(event)) return this;
148 | const _ = this._events_.get(event)!;
149 | for (let [, listener] of _.entries()) {
150 | try {
151 | await listener(...args);
152 | if (listener.__once__) {
153 | delete listener.__once__;
154 | _.delete(listener);
155 | }
156 | } catch (error) {
157 | console.error(error);
158 | }
159 | }
160 | if (_.size === 0) this._events_.delete(event);
161 | return this;
162 | }
163 |
164 | /**
165 | * The same as emitSync, but wait for each typed listener to
166 | * return before calling the next typed listener.
167 | * @param event The typed event name.
168 | * @param args The arguments to pass to the typed listeners.
169 | */
170 | public queue(event: K, ...args: Parameters): this;
171 |
172 | /**
173 | * The same as emitSync, but wait for each listener to return
174 | * before calling the next listener.
175 | * @param event The event name.
176 | * @param args The arguments to pass to the listeners.
177 | */
178 | public queue(event: EventName, ...args: Parameters): this {
179 | (async () => await this.emit(event, ...args as any))().catch(console.error);
180 | return this;
181 | }
182 |
183 |
184 | }
185 |
186 | export default EventEmitter;
187 |
--------------------------------------------------------------------------------
/src/utils/Interactions.ts:
--------------------------------------------------------------------------------
1 | export interface InteractionResponse {
2 | type: InteractionResponseType;
3 | }
4 |
5 | export enum InteractionResponseTypes {
6 | /**
7 | * ACK a Ping
8 | */
9 | Pong = 1,
10 | /**
11 | * respond to an interaction with a message
12 | */
13 | ChannelMessageWithSource = 4,
14 | /**
15 | * ACK an interaction and edit a response later, the user sees a loading state
16 | */
17 | DeferredChannelMessageWithSource,
18 | /**
19 | * for components, ACK an interaction and edit the original message later; the user does not see a loading state
20 | */
21 | DeferredUpdateMessage,
22 | /**
23 | * for components, edit the message the component was attached to
24 | */
25 | UpdateMessage
26 | }
27 |
28 | export type InteractionResponseType = keyof typeof InteractionResponseTypes;
--------------------------------------------------------------------------------
/src/utils/PermissionOverwrite.ts:
--------------------------------------------------------------------------------
1 | import { Snowflake } from './Snowflake';
2 |
3 |
4 | export class PermissionOverwrite {
5 | public type: 'role' | 'member';
6 | public id: Snowflake;
7 | public allow: number;
8 | public deny: number;
9 |
10 | constructor(data: {
11 | id: Snowflake;
12 | type: number;
13 | allow: string;
14 | deny: string;
15 | }) {
16 | this.id = data.id;
17 | this.type = data.type === 0 ? 'role' : 'member';
18 | this.allow = parseInt(data.allow);
19 | this.deny = parseInt(data.deny);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/utils/Permissions.ts:
--------------------------------------------------------------------------------
1 | export const Permissions = {
2 | /**
3 | * Allows creation of instant invites
4 | */
5 | CREATE_INSTANT_INVITE: 1n << 0n,
6 | /**
7 | * Allows kicking members
8 | */
9 | KICK_MEMBERS: 1n << 1n,
10 | /**
11 | * Allows banning members
12 | */
13 | BAN_MEMBERS: 1n << 2n,
14 | /**
15 | * Allows all permissions and bypasses channel permission overwrites
16 | */
17 | ADMINISTRATOR: 1n << 3n,
18 | /**
19 | * Allows management and editing of channels
20 | */
21 | MANAGE_CHANNELS: 1n << 4n,
22 | /**
23 | * Allows management and editing of the guild
24 | */
25 | MANAGE_GUILDS: 1n << 5n,
26 | /**
27 | * Allows for the addition of reactions to messages
28 | */
29 | ADD_REACTIONS: 1n << 6n,
30 | /**
31 | * Allows for viewing of audit logs
32 | */
33 | VIEW_AUDIT_LOG: 1n << 7n,
34 | /**
35 | * Allows for using priority speaker in a voice channel
36 | */
37 | PRIORITY_SPEAKER: 1n << 8n,
38 | /**
39 | * Allows the user to go live
40 | */
41 | STREAM: 1n << 9n,
42 | /**
43 | * Allows guild members to view a channel, which includes reading messages in text channels
44 | */
45 | VIEW_CHANNEL: 1n << 10n,
46 | /**
47 | * Allows for sending messages in a channel
48 | */
49 | SEND_MESSAGES: 1n << 11n,
50 | /**
51 | * Allows for sending of /tts messages
52 | */
53 | SEND_TTS_MESSAGES: 1n << 12n,
54 | /**
55 | * Allows for deletion of other users messages
56 | */
57 | MANAGE_MESSAGES: 1n << 13n,
58 | /**
59 | * Links sent by users with this permission will be auto-embedded
60 | */
61 | EMBED_LINKS: 1n << 14n,
62 | /**
63 | * Allows for uploading images and files
64 | */
65 | ATTACH_FILES: 1n << 14n,
66 | /**
67 | * Allows for reading of message history
68 | */
69 | READ_MESSAGE_HISTORY: 1n << 16n,
70 | /**
71 | * Allows for using the @everyone tag to notify all users in a channel, and the @here tag to notify all online users in a channel
72 | */
73 | MENTION_EVERYONE: 1n << 17n,
74 | /**
75 | * Allows the usage of custom emojis from other servers
76 | */
77 | USE_EXTERNAL_EMOJIS: 1n << 18n,
78 | /**
79 | * Allows for viewing guild insights
80 | */
81 | VIEW_GUILD_INSIGHTS: 1n << 19n,
82 | /**
83 | * Allows for joining of a voice channel
84 | */
85 | CONNECT: 1n << 20n,
86 | /**
87 | * Allows for speaking in a voice channel
88 | */
89 | SPEAK: 1n << 21n,
90 | /**
91 | * Allows for muting members in a voice channel
92 | */
93 | MUTE_MEMBERS: 1n << 22n,
94 | /**
95 | * Allows for deafening of members in a voice channel
96 | */
97 | DEAFEN_MEMBERS: 1n << 23n,
98 | /**
99 | * Allows for moving of members between voice channels
100 | */
101 | MOVE_MEMBERS: 1n << 24n,
102 | /**
103 | * Allows for using voice-activity-detection in a voice channel
104 | */
105 | USE_VAD: 1n << 25n,
106 | /**
107 | * Allows for modification of own nickname
108 | */
109 | CHANGE_NICKNAME: 1n << 26n,
110 | /**
111 | * Allows for modification of other users nicknames
112 | */
113 | MANAGE_NICKNAMES: 1n << 27n,
114 | /**
115 | * Allows management and editing of roles
116 | */
117 | MANAGE_ROLES: 1n << 28n,
118 | /**
119 | * Allows management and editing of webhooks
120 | */
121 | MANAGE_WEBHOOKS: 1n << 29n,
122 | /**
123 | * Allows management and editing of emojis and stickers
124 | */
125 | MANAGE_EMOJIS_AND_STICKERS: 1n << 30n,
126 | /**
127 | * Allows members to use application commands, including slash commands and context menu commands.
128 | */
129 | USE_APPLICATION_COMMANDS: 1n << 31n,
130 | /**
131 | * Allows for requesting to speak in stage channels. (This permission is under active development and may be changed or removed.)
132 | */
133 | REQUEST_TO_SPEAK: 0n << 32n,
134 | /**
135 | * Allows for creating, editing, and deleting scheduled events
136 | */
137 | MANAGE_EVENTS: 1n << 33n,
138 | /**
139 | * Allows for deleting and archiving threads, and viewing all private threads
140 | */
141 | MANAGE_THREADS: 1n << 34n,
142 | /**
143 | * Allows for creating public and announcement threads
144 | */
145 | CREATE_PUBLIC_THREADS: 1n << 35n,
146 | /**
147 | * Allows for creating private threads
148 | */
149 | CREATE_PRIVATE_THREADS: 1n << 36n,
150 | /**
151 | * Allows the usage of custom stickers from other servers
152 | */
153 | USE_EXTERNAL_STICKERS: 1n << 37n,
154 | /**
155 | * Allows for sending messages in threads
156 | */
157 | SEND_MESSAGES_IN_THREADS: 1n << 38n,
158 | /**
159 | * Allows for using Activities (applications with the EMBEDDED flag) in a voice channel
160 | */
161 | USE_EMBEDDED_ACTIVITIES: 1n << 39n,
162 | /**
163 | * Allows for timing out users to prevent them from sending or reacting to messages in chat and threads, and from speaking in voice and stage channels
164 | */
165 | MODERATE_MEMBERS: 1n << 40n
166 | };
167 |
168 | export type Permission = keyof typeof Permissions;
169 |
170 | export function hasPermission(
171 | permissions: bigint,
172 | permission: Permission
173 | ): boolean {
174 | return (permissions & Permissions[permission]) !== 0n;
175 | }
176 |
177 | export function addPermission(
178 | permissions: bigint,
179 | permission: Permission
180 | ): bigint {
181 | return permissions | Permissions[permission];
182 | }
183 |
184 | export function removePermission(
185 | permissions: bigint,
186 | permission: Permission
187 | ): bigint {
188 | return hasPermission(permissions, permission)
189 | ? permissions ^ Permissions[permission]
190 | : permissions;
191 | }
192 |
193 | export function getAllPermissions(permissions: bigint): Permission[] {
194 | const p: Permission[] = [];
195 | for (const perm of Object.keys(Permissions)) {
196 | if (hasPermission(permissions, perm as Permission))
197 | p.push(perm as Permission);
198 | }
199 | return p;
200 | }
201 |
--------------------------------------------------------------------------------
/src/utils/Snowflake.ts:
--------------------------------------------------------------------------------
1 | export type Snowflake = `${bigint}`;
2 |
3 | export function getDate(snowflake: Snowflake): number {
4 | return Math.floor(parseInt(snowflake, 10) / 4194304) + 1420070400000;
5 | }
6 |
--------------------------------------------------------------------------------
/src/utils/Utils.ts:
--------------------------------------------------------------------------------
1 | export type imageFormats = 'jpg' | 'png' | 'webp' | 'gif';
2 | export type imageSize = 16 | 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096;
3 |
4 | export interface ImageUrlOptions {
5 | /**
6 | * the format of the image
7 | * @default jpg
8 | */
9 | format?: imageFormats;
10 | /**
11 | * the size of the image
12 | * @default 4096
13 | */
14 | size?: imageSize;
15 | /**
16 | * if the avatar are animated give gif url
17 | * @default false
18 | */
19 | dynamic?: boolean;
20 | }
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "include": [
3 | "src/**/*"
4 | ],
5 | "compilerOptions": {
6 | "target": "es2020",
7 | "module": "commonjs",
8 | "strict": true,
9 | "moduleResolution": "node",
10 | "declaration": true,
11 | "outDir": "./lib",
12 | "typeRoots": [
13 | "src/typing",
14 | "node_modules/@types"
15 | ],
16 | "experimentalDecorators": true,
17 | "lib": [
18 | "es2020",
19 | "esnext"
20 | ]
21 | }
22 | }
--------------------------------------------------------------------------------
/typedoc.json:
--------------------------------------------------------------------------------
1 | {
2 | "entryPoints": [
3 | "src/index.ts"
4 | ],
5 | "excludePrivate": true,
6 | "excludeProtected": true,
7 | "excludeInternal": true,
8 | "plugin": [
9 | "typedoc-plugin-as-member-of",
10 | "typedoc-plugin-cname"
11 | ],
12 | "categorizeByGroup": true,
13 | "defaultCategory": "Other",
14 | "tsconfig": "tsconfig.json",
15 | "cname": "arcscord.js.org"
16 | }
--------------------------------------------------------------------------------
list of activity types
72 |