discordeno 16.0.0 → 17.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -69
- package/esm/gateway/shard/connect.js +7 -3
- package/esm/helpers/channels/mod.js +0 -1
- package/esm/helpers/guilds/invites/createInvite.js +1 -0
- package/esm/helpers/interactions/responses/editFollowupMessage.js +2 -1
- package/esm/helpers/interactions/responses/editOriginalInteractionResponse.js +7 -4
- package/esm/helpers/misc/getNitroStickerPacks.js +8 -1
- package/esm/helpers/mod.js +1 -0
- package/esm/helpers/stickers/createGuildSticker.js +25 -0
- package/esm/helpers/stickers/deleteGuildSticker.js +18 -0
- package/esm/helpers/stickers/editGuildSticker.js +22 -0
- package/esm/helpers/stickers/getGuildSticker.js +16 -0
- package/esm/helpers/stickers/getGuildStickers.js +19 -0
- package/esm/helpers/stickers/getSticker.js +13 -0
- package/esm/helpers/stickers/mod.js +6 -0
- package/esm/helpers/webhooks/editOriginalWebhookMessage.js +7 -4
- package/esm/helpers/webhooks/editWebhookMessage.js +7 -4
- package/esm/helpers/{channels → webhooks}/getChannelWebhooks.js +0 -0
- package/esm/helpers/webhooks/{getWebhooks.js → getGuildWebhooks.js} +1 -1
- package/esm/helpers/webhooks/mod.js +2 -1
- package/esm/plugins/permissions/mod.js +2 -0
- package/esm/plugins/permissions/src/channels/createChannel.js +2 -2
- package/esm/plugins/permissions/src/channels/deleteChannel.js +2 -2
- package/esm/plugins/permissions/src/channels/deleteChannelPermissionOverride.js +2 -2
- package/esm/plugins/permissions/src/channels/editChannel.js +2 -2
- package/esm/plugins/permissions/src/channels/editChannelPermissionOverrides.js +2 -2
- package/esm/plugins/permissions/src/channels/followAnnouncementChannel.js +4 -4
- package/esm/plugins/permissions/src/channels/forums/createForumThread.js +2 -2
- package/esm/plugins/permissions/src/channels/getChannelWebhooks.js +2 -2
- package/esm/plugins/permissions/src/channels/stages/createStageInstance.js +2 -2
- package/esm/plugins/permissions/src/channels/stages/deleteStageInstances.js +2 -2
- package/esm/plugins/permissions/src/channels/stages/editStageInstance.js +2 -2
- package/esm/plugins/permissions/src/channels/threads/addThreadMember.js +1 -1
- package/esm/plugins/permissions/src/channels/threads/getPrivateArchivedThreads.js +6 -2
- package/esm/plugins/permissions/src/channels/threads/getPrivateJoinedArchivedThreads.js +2 -2
- package/esm/plugins/permissions/src/channels/threads/getPublicArchivedThreads.js +2 -2
- package/esm/plugins/permissions/src/channels/threads/joinThread.js +2 -2
- package/esm/plugins/permissions/src/channels/threads/leaveThread.js +2 -2
- package/esm/plugins/permissions/src/channels/threads/removeThreadMember.js +1 -1
- package/esm/plugins/permissions/src/emojis/createEmoji.js +1 -1
- package/esm/plugins/permissions/src/emojis/deleteEmoji.js +1 -1
- package/esm/plugins/permissions/src/emojis/editEmoji.js +1 -1
- package/esm/plugins/permissions/src/guilds/automod/createAutomodRule.js +2 -2
- package/esm/plugins/permissions/src/guilds/automod/deleteAutomodRule.js +1 -1
- package/esm/plugins/permissions/src/guilds/automod/editAutomodRule.js +2 -2
- package/esm/plugins/permissions/src/guilds/automod/getAutomodRule.js +1 -1
- package/esm/plugins/permissions/src/guilds/automod/getAutomodRules.js +1 -1
- package/esm/plugins/permissions/src/guilds/deleteGuild.js +1 -1
- package/esm/plugins/permissions/src/guilds/editGuild.js +2 -2
- package/esm/plugins/permissions/src/guilds/editGuildMfaLevel.js +1 -1
- package/esm/plugins/permissions/src/guilds/editWelcomeScreen.js +1 -1
- package/esm/plugins/permissions/src/guilds/events/createScheduledEvent.js +7 -7
- package/esm/plugins/permissions/src/guilds/events/editScheduledEvent.js +7 -7
- package/esm/plugins/permissions/src/guilds/getAuditLog.js +1 -1
- package/esm/plugins/permissions/src/guilds/getBan.js +1 -1
- package/esm/plugins/permissions/src/guilds/getBans.js +1 -1
- package/esm/plugins/permissions/src/guilds/getPruneCount.js +1 -1
- package/esm/plugins/permissions/src/guilds/getVanityUrl.js +1 -1
- package/esm/plugins/permissions/src/guilds/getWelcomeScreen.js +2 -2
- package/esm/plugins/permissions/src/guilds/voice/connectToVoiceChannels.js +2 -2
- package/esm/plugins/permissions/src/guilds/widgets/editWidgetSettings.js +1 -1
- package/esm/plugins/permissions/src/integrations/deleteIntegrations.js +1 -1
- package/esm/plugins/permissions/src/integrations/getIntegrations.js +1 -1
- package/esm/plugins/permissions/src/members/banMember.js +1 -1
- package/esm/plugins/permissions/src/members/editBotMember.js +1 -1
- package/esm/plugins/permissions/src/members/editMember.js +4 -4
- package/esm/plugins/permissions/src/members/kickMember.js +1 -1
- package/esm/plugins/permissions/src/members/pruneMembers.js +1 -1
- package/esm/plugins/permissions/src/members/unbanMember.js +1 -1
- package/esm/plugins/permissions/src/messages/deleteMessage.js +2 -2
- package/esm/plugins/permissions/src/messages/deleteMessages.js +1 -1
- package/esm/plugins/permissions/src/messages/getMessage.js +1 -1
- package/esm/plugins/permissions/src/messages/getMessages.js +1 -1
- package/esm/plugins/permissions/src/messages/pinMessage.js +1 -1
- package/esm/plugins/permissions/src/messages/reactions/addReaction.js +1 -1
- package/esm/plugins/permissions/src/messages/reactions/addReactions.js +1 -1
- package/esm/plugins/permissions/src/messages/reactions/deleteReactionsAll.js +1 -1
- package/esm/plugins/permissions/src/messages/reactions/deleteReactionsEmoji.js +1 -1
- package/esm/plugins/permissions/src/messages/reactions/deleteUserReaction.ts.js +1 -1
- package/esm/plugins/permissions/src/messages/sendMessage.js +1 -1
- package/esm/plugins/permissions/src/messages/unpinMessage.js +1 -1
- package/esm/plugins/permissions/src/permissions.js +0 -20
- package/esm/plugins/permissions/src/roles/addRole.js +2 -2
- package/esm/plugins/permissions/src/roles/createRole.js +1 -1
- package/esm/plugins/permissions/src/roles/deleteRole.js +1 -1
- package/esm/plugins/permissions/src/roles/editRole.js +2 -2
- package/esm/plugins/permissions/src/roles/modifyRolePositions.js +1 -1
- package/esm/plugins/permissions/src/roles/removeRole.js +2 -2
- package/esm/plugins/permissions/src/stickers/createGuildSticker.js +8 -0
- package/esm/plugins/permissions/src/stickers/deleteGuildSticker.js +8 -0
- package/esm/plugins/permissions/src/stickers/editGuildSticker.js +8 -0
- package/esm/plugins/permissions/src/stickers/mod.js +8 -0
- package/esm/plugins/permissions/src/webhooks/createWebhook.js +1 -1
- package/esm/plugins/permissions/src/webhooks/deleteWebhook.js +1 -1
- package/esm/plugins/permissions/src/webhooks/editWebhook.js +6 -2
- package/esm/plugins/validations/mod.js +2 -0
- package/esm/plugins/validations/src/messages/deleteMessages.js +1 -1
- package/esm/plugins/validations/src/stickers/createGuildSticker.js +16 -0
- package/esm/plugins/validations/src/stickers/editGuildSticker.js +17 -0
- package/esm/plugins/validations/src/stickers/mod.js +6 -0
- package/esm/rest/createRequestBody.js +12 -4
- package/esm/rest/processGlobalQueue.js +4 -0
- package/esm/rest/runMethod.js +13 -1
- package/esm/rest/sendRequest.js +7 -0
- package/esm/transformers/component.js +2 -0
- package/esm/transformers/reverse/component.js +3 -0
- package/esm/transformers/toggles/guild.js +47 -20
- package/esm/types/shared.js +3 -5
- package/esm/util/constants.js +1 -1
- package/esm/util/routes.js +11 -2
- package/package.json +1 -1
- package/script/gateway/shard/connect.js +7 -3
- package/script/helpers/channels/mod.js +0 -1
- package/script/helpers/guilds/invites/createInvite.js +1 -0
- package/script/helpers/interactions/responses/editFollowupMessage.js +2 -1
- package/script/helpers/interactions/responses/editOriginalInteractionResponse.js +7 -4
- package/script/helpers/misc/getNitroStickerPacks.js +8 -1
- package/script/helpers/mod.js +1 -0
- package/script/helpers/stickers/createGuildSticker.js +29 -0
- package/script/helpers/stickers/deleteGuildSticker.js +22 -0
- package/script/helpers/stickers/editGuildSticker.js +26 -0
- package/script/helpers/stickers/getGuildSticker.js +20 -0
- package/script/helpers/stickers/getGuildStickers.js +23 -0
- package/script/helpers/stickers/getSticker.js +17 -0
- package/script/helpers/stickers/mod.js +22 -0
- package/script/helpers/webhooks/editOriginalWebhookMessage.js +7 -4
- package/script/helpers/webhooks/editWebhookMessage.js +7 -4
- package/script/helpers/{channels → webhooks}/getChannelWebhooks.js +0 -0
- package/script/helpers/webhooks/{getWebhooks.js → getGuildWebhooks.js} +3 -3
- package/script/helpers/webhooks/mod.js +2 -1
- package/script/plugins/permissions/mod.js +4 -2
- package/script/plugins/permissions/src/channels/createChannel.js +2 -2
- package/script/plugins/permissions/src/channels/deleteChannel.js +2 -2
- package/script/plugins/permissions/src/channels/deleteChannelPermissionOverride.js +2 -2
- package/script/plugins/permissions/src/channels/editChannel.js +2 -2
- package/script/plugins/permissions/src/channels/editChannelPermissionOverrides.js +2 -2
- package/script/plugins/permissions/src/channels/followAnnouncementChannel.js +4 -4
- package/script/plugins/permissions/src/channels/forums/createForumThread.js +2 -2
- package/script/plugins/permissions/src/channels/getChannelWebhooks.js +2 -2
- package/script/plugins/permissions/src/channels/stages/createStageInstance.js +2 -2
- package/script/plugins/permissions/src/channels/stages/deleteStageInstances.js +2 -2
- package/script/plugins/permissions/src/channels/stages/editStageInstance.js +2 -2
- package/script/plugins/permissions/src/channels/threads/addThreadMember.js +1 -1
- package/script/plugins/permissions/src/channels/threads/getPrivateArchivedThreads.js +6 -2
- package/script/plugins/permissions/src/channels/threads/getPrivateJoinedArchivedThreads.js +2 -2
- package/script/plugins/permissions/src/channels/threads/getPublicArchivedThreads.js +2 -2
- package/script/plugins/permissions/src/channels/threads/joinThread.js +2 -2
- package/script/plugins/permissions/src/channels/threads/leaveThread.js +2 -2
- package/script/plugins/permissions/src/channels/threads/removeThreadMember.js +1 -1
- package/script/plugins/permissions/src/emojis/createEmoji.js +1 -1
- package/script/plugins/permissions/src/emojis/deleteEmoji.js +1 -1
- package/script/plugins/permissions/src/emojis/editEmoji.js +1 -1
- package/script/plugins/permissions/src/guilds/automod/createAutomodRule.js +2 -2
- package/script/plugins/permissions/src/guilds/automod/deleteAutomodRule.js +1 -1
- package/script/plugins/permissions/src/guilds/automod/editAutomodRule.js +2 -2
- package/script/plugins/permissions/src/guilds/automod/getAutomodRule.js +1 -1
- package/script/plugins/permissions/src/guilds/automod/getAutomodRules.js +1 -1
- package/script/plugins/permissions/src/guilds/deleteGuild.js +1 -1
- package/script/plugins/permissions/src/guilds/editGuild.js +2 -2
- package/script/plugins/permissions/src/guilds/editGuildMfaLevel.js +1 -1
- package/script/plugins/permissions/src/guilds/editWelcomeScreen.js +1 -1
- package/script/plugins/permissions/src/guilds/events/createScheduledEvent.js +7 -7
- package/script/plugins/permissions/src/guilds/events/editScheduledEvent.js +7 -7
- package/script/plugins/permissions/src/guilds/getAuditLog.js +1 -1
- package/script/plugins/permissions/src/guilds/getBan.js +1 -1
- package/script/plugins/permissions/src/guilds/getBans.js +1 -1
- package/script/plugins/permissions/src/guilds/getPruneCount.js +1 -1
- package/script/plugins/permissions/src/guilds/getVanityUrl.js +1 -1
- package/script/plugins/permissions/src/guilds/getWelcomeScreen.js +2 -2
- package/script/plugins/permissions/src/guilds/voice/connectToVoiceChannels.js +2 -2
- package/script/plugins/permissions/src/guilds/widgets/editWidgetSettings.js +1 -1
- package/script/plugins/permissions/src/integrations/deleteIntegrations.js +1 -1
- package/script/plugins/permissions/src/integrations/getIntegrations.js +1 -1
- package/script/plugins/permissions/src/members/banMember.js +1 -1
- package/script/plugins/permissions/src/members/editBotMember.js +1 -1
- package/script/plugins/permissions/src/members/editMember.js +4 -4
- package/script/plugins/permissions/src/members/kickMember.js +1 -1
- package/script/plugins/permissions/src/members/pruneMembers.js +1 -1
- package/script/plugins/permissions/src/members/unbanMember.js +1 -1
- package/script/plugins/permissions/src/messages/deleteMessage.js +2 -2
- package/script/plugins/permissions/src/messages/deleteMessages.js +1 -1
- package/script/plugins/permissions/src/messages/getMessage.js +1 -1
- package/script/plugins/permissions/src/messages/getMessages.js +1 -1
- package/script/plugins/permissions/src/messages/pinMessage.js +1 -1
- package/script/plugins/permissions/src/messages/reactions/addReaction.js +1 -1
- package/script/plugins/permissions/src/messages/reactions/addReactions.js +1 -1
- package/script/plugins/permissions/src/messages/reactions/deleteReactionsAll.js +1 -1
- package/script/plugins/permissions/src/messages/reactions/deleteReactionsEmoji.js +1 -1
- package/script/plugins/permissions/src/messages/reactions/deleteUserReaction.ts.js +1 -1
- package/script/plugins/permissions/src/messages/sendMessage.js +1 -1
- package/script/plugins/permissions/src/messages/unpinMessage.js +1 -1
- package/script/plugins/permissions/src/permissions.js +1 -23
- package/script/plugins/permissions/src/roles/addRole.js +2 -2
- package/script/plugins/permissions/src/roles/createRole.js +1 -1
- package/script/plugins/permissions/src/roles/deleteRole.js +1 -1
- package/script/plugins/permissions/src/roles/editRole.js +2 -2
- package/script/plugins/permissions/src/roles/modifyRolePositions.js +1 -1
- package/script/plugins/permissions/src/roles/removeRole.js +2 -2
- package/script/plugins/permissions/src/stickers/createGuildSticker.js +12 -0
- package/script/plugins/permissions/src/stickers/deleteGuildSticker.js +12 -0
- package/script/plugins/permissions/src/stickers/editGuildSticker.js +12 -0
- package/script/plugins/permissions/src/stickers/mod.js +12 -0
- package/script/plugins/permissions/src/webhooks/createWebhook.js +1 -1
- package/script/plugins/permissions/src/webhooks/deleteWebhook.js +1 -1
- package/script/plugins/permissions/src/webhooks/editWebhook.js +6 -2
- package/script/plugins/validations/mod.js +4 -2
- package/script/plugins/validations/src/messages/deleteMessages.js +1 -1
- package/script/plugins/validations/src/stickers/createGuildSticker.js +20 -0
- package/script/plugins/validations/src/stickers/editGuildSticker.js +21 -0
- package/script/plugins/validations/src/stickers/mod.js +10 -0
- package/script/rest/createRequestBody.js +12 -4
- package/script/rest/processGlobalQueue.js +4 -0
- package/script/rest/runMethod.js +13 -1
- package/script/rest/sendRequest.js +7 -0
- package/script/transformers/component.js +2 -0
- package/script/transformers/reverse/component.js +3 -0
- package/script/transformers/toggles/guild.js +47 -20
- package/script/types/shared.js +3 -5
- package/script/util/constants.js +1 -1
- package/script/util/routes.js +11 -2
- package/types/bot.d.ts +25 -5
- package/types/helpers/channels/createChannel.d.ts +1 -1
- package/types/helpers/channels/mod.d.ts +0 -1
- package/types/helpers/misc/getNitroStickerPacks.d.ts +8 -1
- package/types/helpers/mod.d.ts +1 -0
- package/types/helpers/stickers/createGuildSticker.d.ts +29 -0
- package/types/helpers/stickers/deleteGuildSticker.d.ts +17 -0
- package/types/helpers/stickers/editGuildSticker.d.ts +26 -0
- package/types/helpers/stickers/getGuildSticker.d.ts +14 -0
- package/types/helpers/stickers/getGuildStickers.d.ts +14 -0
- package/types/helpers/stickers/getSticker.d.ts +12 -0
- package/types/helpers/stickers/mod.d.ts +6 -0
- package/types/helpers/{channels → webhooks}/getChannelWebhooks.d.ts +0 -0
- package/types/helpers/webhooks/{getWebhooks.d.ts → getGuildWebhooks.d.ts} +1 -1
- package/types/helpers/webhooks/mod.d.ts +2 -1
- package/types/plugins/cache/src/addCacheCollections.d.ts +2 -2
- package/types/plugins/permissions/src/permissions.d.ts +0 -4
- package/types/plugins/permissions/src/stickers/createGuildSticker.d.ts +2 -0
- package/types/plugins/permissions/src/stickers/deleteGuildSticker.d.ts +2 -0
- package/types/plugins/permissions/src/stickers/editGuildSticker.d.ts +2 -0
- package/types/plugins/permissions/src/stickers/mod.d.ts +2 -0
- package/types/plugins/validations/src/stickers/createGuildSticker.d.ts +2 -0
- package/types/plugins/validations/src/stickers/editGuildSticker.d.ts +2 -0
- package/types/plugins/validations/src/stickers/mod.d.ts +2 -0
- package/types/rest/createRequestBody.d.ts +1 -0
- package/types/rest/runMethod.d.ts +1 -1
- package/types/rest/sendRequest.d.ts +1 -0
- package/types/transformers/component.d.ts +6 -0
- package/types/transformers/interaction.d.ts +222 -48
- package/types/transformers/message.d.ts +3 -0
- package/types/transformers/toggles/guild.d.ts +8 -11
- package/types/types/discord.d.ts +10 -2
- package/types/types/shared.d.ts +4 -6
- package/types/util/constants.d.ts +1 -1
- package/types/util/routes.d.ts +3 -0
package/README.md
CHANGED
|
@@ -6,88 +6,90 @@ Discord API library for [Deno](https://deno.land)
|
|
|
6
6
|
|
|
7
7
|
Discordeno follows [semantic versioning](https://semver.org/)
|
|
8
8
|
|
|
9
|
-
<!-- TODO: add coverage back when it is stable -->
|
|
10
|
-
|
|
11
9
|
[](https://discord.com/invite/5vBgXk3UcZ)
|
|
12
10
|

|
|
13
11
|
[](https://codecov.io/gh/discordeno/discordeno)
|
|
14
12
|
|
|
15
13
|
## Features
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- **
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
15
|
+
Discordeno is actively maintained to guarantee **excellent performance and ease.**
|
|
16
|
+
|
|
17
|
+
- **Simple, Efficient, and Lightweight**: Discordeno is lightweight, simple to use, and adaptable. By default, no
|
|
18
|
+
caching.
|
|
19
|
+
- **Functional API**: The functional API eliminates the challenges of extending built-in classes and inheritance while
|
|
20
|
+
ensuring overall simple but performant code.
|
|
21
|
+
- **Cross Runtime**: Supports the Node.js and Deno runtimes.
|
|
22
|
+
- **Standalone components**: Discordeno offers the option to have practically any component of a bot as a separate
|
|
23
|
+
piece, including standalone REST, gateways, custom caches, and more.
|
|
24
|
+
- **Plugins:** Designed to allow you to overwrite any portion of the code with your own code. Never go through the
|
|
25
|
+
hassle of maintaining your fork in order to acquire something that is specifically tailored to your requirements.
|
|
26
|
+
Plugins may be used for nearly anything; for instance, we have a few authorised plugins.
|
|
27
|
+
- A caching plugin that makes anything cacheable.
|
|
28
|
+
- A plugin for sweepers that allows them to periodically clear the cache.
|
|
29
|
+
- The permission plugin internally verifies any missing permissions before sending a call to the Discord API to
|
|
30
|
+
prevent the client from receiving a Discord global ban.
|
|
31
|
+
|
|
32
|
+
- **Flexibility:** You may easily delete an object's attributes if your bot doesn't require them. For instance, you
|
|
33
|
+
shouldn't be required to keep `Channel.topic` if your bot doesn't require it. You may save GBs of RAM in this way. A
|
|
34
|
+
few lines of code are all that are needed to accomplish this for any property on any object.
|
|
35
35
|
|
|
36
36
|
### REST
|
|
37
37
|
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
|
|
41
|
-
-
|
|
42
|
-
- ✅ As your bot grows, you want to handle global rate limits better. Shards don't communicate fast enough to truly
|
|
38
|
+
- Freedom from 1 hour downtimes due to invalid requests
|
|
39
|
+
- By lowering the maximum downtime to 10 minutes, Discordeno will prevent your bot from being down for an hour.
|
|
40
|
+
- Freedom from global rate limit errors
|
|
41
|
+
- As your bot grows, you want to handle global rate limits better. Shards don't communicate fast enough to truly
|
|
43
42
|
handle it properly so this allows 1 rest handler across the entire bot.
|
|
44
|
-
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
43
|
+
- You may really run numerous instances of your bot on different hosts, all of which will connect to the same REST
|
|
44
|
+
server.
|
|
45
|
+
- REST does not rest!
|
|
46
|
+
- Separate rest guarantees that your queued requests will continue to be processed even if your bot breaks for
|
|
47
|
+
whatever reason.
|
|
48
|
+
- Seamless updates! There's a chance you'll lose a lot of messages or replies that are waiting to be given when you
|
|
49
|
+
wish to update and restart the bot. You may restart your bot using this technique and never have to worry about
|
|
50
|
+
losing any answers.
|
|
51
|
+
- Single source of contact to Discord API
|
|
52
|
+
- As a result, you will be able to send requests to Discord from any location, even a bot dashboard. You are no longer
|
|
53
|
+
need to interact with your bot processes in order to submit a request or do anything else. Your bot process should
|
|
54
|
+
be freed up to handle bot events.
|
|
55
|
+
- Scalability! Scalability! Scalability!
|
|
55
56
|
|
|
56
57
|
### Gateway
|
|
57
58
|
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
process identifying all your shards
|
|
61
|
-
you
|
|
62
|
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
65
|
-
150,000 servers
|
|
66
|
-
|
|
67
|
-
-
|
|
68
|
-
-
|
|
59
|
+
- **Zero Downtime Updates:**
|
|
60
|
+
- A few seconds are needed to update your bot. When using conventional sharding, you must restart in addition to going
|
|
61
|
+
through a 1/5s rate-limited process of identifying all of your shards. As WS processing has been relocated to a
|
|
62
|
+
proxy process, you may resume the bot code right away without worrying about any delays. Normally, if you had a bot
|
|
63
|
+
that was spread across 200,000 servers, restarting it after making a simple modification would take 20 minutes.
|
|
64
|
+
- **Zero Downtime Resharding:**
|
|
65
|
+
- At various periods in time, Discord stops allowing your bot to be added to new servers. Consider 150 shards
|
|
66
|
+
operating on 150,000 servers, for instance. Your shards may support a maximum of 150 * 2500 = 375,000 servers. Your
|
|
67
|
+
bot will be unable to join new servers once it reaches this point until it re-shards.
|
|
68
|
+
- DD proxy provides 2 types of re-sharding. Automated and manual. You can also have both.
|
|
69
|
+
- Automated: This system will automatically begin a Zero-downtime resharding process behind the scenes when you
|
|
69
70
|
reach 80% of your maximum servers allowed by your shards. For example, since 375,000 was the max, at 300,000 we
|
|
70
71
|
would begin re-sharding behind the scenes with ZERO DOWNTIME.
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
-
|
|
74
|
-
-
|
|
75
|
-
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
-
|
|
79
|
-
-
|
|
80
|
-
or messages
|
|
81
|
-
who
|
|
82
|
-
restarting your bot
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
72
|
+
- 80% of maximum servers reached (The % of 80% is customizable.)
|
|
73
|
+
- Identify limits have room to allow re-sharding. (Also customizable)
|
|
74
|
+
- Manual: You can also trigger this manually should you choose.
|
|
75
|
+
- **Horizontal Scaling:**
|
|
76
|
+
- The bot may be scaled horizontally thanks to the proxy mechanism. When your business grows significantly, you have
|
|
77
|
+
two options: you can either keep investing money to upgrade your server or you may expand horizontally by purchasing
|
|
78
|
+
numerous more affordable servers. The proxy enables WS handling on a totally other system.
|
|
79
|
+
- **No Loss Restarts:**
|
|
80
|
+
- Without the proxy mechanism, you would typically lose numerous events while restarting a bot. Users could issue
|
|
81
|
+
instructions or send messages that are not screened. As your bot population increases, this amount grows sharply.
|
|
82
|
+
Users who don't receive the automatic roles or any other activities your bot should do may join. You may keep
|
|
83
|
+
restarting your bot thanks to the proxy technology without ever losing any events. While your bot is unavailable,
|
|
84
|
+
events will be added to a queue (the maximum size of the queue is configurable), and once the bot is back online,
|
|
85
|
+
the queue will start processing all of the events.
|
|
86
|
+
- **Controllers:**
|
|
87
|
+
- You have complete control over everything inside the proxy thanks to the controller aspect. To simply override the
|
|
88
|
+
handler, you may supply a function. For instance, you may simply give a method to override a specific function if
|
|
89
|
+
you want it to behave differently rather than forking and maintaining your fork.
|
|
90
|
+
- **Clustering With Workers:**
|
|
91
|
+
- Utilize all of your CPU cores to their greatest potential by distributing the workload across employees. To enhance
|
|
92
|
+
efficiency, manage how many employees and shards there are each worker!
|
|
91
93
|
|
|
92
94
|
### Custom Cache
|
|
93
95
|
|
|
@@ -122,8 +124,8 @@ await startBot(bot);
|
|
|
122
124
|
|
|
123
125
|
### Tools
|
|
124
126
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
+
This library is not intended for beginners, however if you still want to utilise it, check out these excellent official
|
|
128
|
+
and unofficial templates:
|
|
127
129
|
|
|
128
130
|
**Templates**
|
|
129
131
|
|
|
@@ -134,6 +136,7 @@ these awesome official and unofficial templates:
|
|
|
134
136
|
|
|
135
137
|
**Frameworks**
|
|
136
138
|
|
|
139
|
+
- [Amethyst Framework](https://github.com/AmethystFramework/framework)
|
|
137
140
|
- [Add Your Own!](https://github.com/discordeno/discordeno/pulls)
|
|
138
141
|
|
|
139
142
|
**Plugins**
|
|
@@ -7,10 +7,14 @@ export async function connect(shard) {
|
|
|
7
7
|
shard.state = ShardState.Connecting;
|
|
8
8
|
}
|
|
9
9
|
shard.events.connecting?.(shard);
|
|
10
|
-
let url = shard.gatewayConfig.url;
|
|
10
|
+
let url = new URL(shard.gatewayConfig.url);
|
|
11
11
|
// If not connecting to a proxy but directly to discord need to handle resuming
|
|
12
|
-
if (url === "wss://gateway.discord.gg") {
|
|
13
|
-
|
|
12
|
+
if (url.origin === "wss://gateway.discord.gg") {
|
|
13
|
+
if (shard.state === ShardState.Resuming) {
|
|
14
|
+
url = new URL(shard.resumeGatewayUrl);
|
|
15
|
+
}
|
|
16
|
+
url.searchParams.set("v", shard.gatewayConfig.version.toString());
|
|
17
|
+
url.searchParams.set("encoding", "json");
|
|
14
18
|
}
|
|
15
19
|
const socket = new dntShim.WebSocket(url);
|
|
16
20
|
shard.socket = socket;
|
|
@@ -10,6 +10,5 @@ export * from "./editChannelPermissionOverrides.js";
|
|
|
10
10
|
export * from "./getChannel.js";
|
|
11
11
|
export * from "./getChannelInvites.js";
|
|
12
12
|
export * from "./getChannels.js";
|
|
13
|
-
export * from "./getChannelWebhooks.js";
|
|
14
13
|
export * from "./triggerTypingIndicator.js";
|
|
15
14
|
export * from "./editChannelPositions.js";
|
|
@@ -25,6 +25,7 @@ export async function createInvite(bot, channelId, options = {}) {
|
|
|
25
25
|
target_type: options.targetType,
|
|
26
26
|
target_user_id: options.targetUserId?.toString(),
|
|
27
27
|
target_application_id: options.targetApplicationId?.toString(),
|
|
28
|
+
reason: options.reason,
|
|
28
29
|
});
|
|
29
30
|
return {
|
|
30
31
|
code: result.code,
|
|
@@ -19,11 +19,12 @@ import { InteractionResponseTypes } from "../../../types/shared.js";
|
|
|
19
19
|
*/
|
|
20
20
|
export async function editFollowupMessage(bot, token, messageId, options) {
|
|
21
21
|
const result = await bot.rest.runMethod(bot.rest, "PATCH", bot.constants.routes.WEBHOOK_MESSAGE(bot.applicationId, token, messageId), {
|
|
22
|
-
messageId,
|
|
22
|
+
messageId: messageId.toString(),
|
|
23
23
|
...bot.transformers.reverse.interactionResponse(bot, {
|
|
24
24
|
type: InteractionResponseTypes.UpdateMessage,
|
|
25
25
|
data: options,
|
|
26
26
|
}).data,
|
|
27
|
+
file: options.file,
|
|
27
28
|
});
|
|
28
29
|
return bot.transformers.message(bot, result);
|
|
29
30
|
}
|
|
@@ -17,9 +17,12 @@ import { InteractionResponseTypes } from "../../../types/mod.js";
|
|
|
17
17
|
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-response}
|
|
18
18
|
*/
|
|
19
19
|
export async function editOriginalInteractionResponse(bot, token, options) {
|
|
20
|
-
const result = await bot.rest.runMethod(bot.rest, "PATCH", bot.constants.routes.INTERACTION_ORIGINAL_ID_TOKEN(bot.applicationId, token),
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const result = await bot.rest.runMethod(bot.rest, "PATCH", bot.constants.routes.INTERACTION_ORIGINAL_ID_TOKEN(bot.applicationId, token), {
|
|
21
|
+
...bot.transformers.reverse.interactionResponse(bot, {
|
|
22
|
+
type: InteractionResponseTypes.UpdateMessage,
|
|
23
|
+
data: options,
|
|
24
|
+
}).data,
|
|
25
|
+
file: options.file,
|
|
26
|
+
});
|
|
24
27
|
return bot.transformers.message(bot, result);
|
|
25
28
|
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { Collection } from "../../util/collection.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Returns the list of sticker packs available to Nitro subscribers.
|
|
4
|
+
*
|
|
5
|
+
* @param bot The bot instance to use to make the request.
|
|
6
|
+
* @returns A collection of {@link StickerPack} objects assorted by sticker ID.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link https://discord.com/developers/docs/resources/sticker#list-nitro-sticker-packs}
|
|
9
|
+
*/
|
|
3
10
|
export async function getNitroStickerPacks(bot) {
|
|
4
11
|
const results = await bot.rest.runMethod(bot.rest, "GET", bot.constants.routes.NITRO_STICKER_PACKS());
|
|
5
12
|
return new Collection(results.map((result) => {
|
package/esm/helpers/mod.js
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a new sticker for the guild.
|
|
3
|
+
*
|
|
4
|
+
* @param bot The bot instance to use to make the request.
|
|
5
|
+
* @param guildId The ID of the guild to get
|
|
6
|
+
* @return A {@link Sticker}
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* Requires the `MANAGE_EMOJIS_AND_STICKERS` permission.
|
|
10
|
+
* Fires a Guild Stickers Update Gateway event.
|
|
11
|
+
* Every guilds has five free sticker slots by default, and each Boost level will grant access to more slots.
|
|
12
|
+
* Lottie stickers can only be uploaded on guilds that have either the `VERIFIED` and/or the `PARTNERED` guild feature.
|
|
13
|
+
*
|
|
14
|
+
* @see {@link https://discord.com/developers/docs/resources/sticker#create-guild-sticker}
|
|
15
|
+
*/
|
|
16
|
+
export async function createGuildSticker(bot, guildId, options) {
|
|
17
|
+
const result = await bot.rest.runMethod(bot.rest, "POST", bot.constants.routes.GUILD_STICKERS(guildId), {
|
|
18
|
+
name: options.name,
|
|
19
|
+
description: options.description,
|
|
20
|
+
tags: options.tags,
|
|
21
|
+
file: options.file,
|
|
22
|
+
reason: options.reason,
|
|
23
|
+
});
|
|
24
|
+
return bot.transformers.sticker(bot, result);
|
|
25
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delete a new sticker for the guild.
|
|
3
|
+
*
|
|
4
|
+
* @param bot The bot instance to use to make the request.
|
|
5
|
+
* @param guildId The ID of the guild to get
|
|
6
|
+
* @return A {@link Sticker}
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* Requires the `MANAGE_EMOJIS_AND_STICKERS` permission.
|
|
10
|
+
* Fires a Guild Stickers Update Gateway event.
|
|
11
|
+
* Every guilds has five free sticker slots by default, and each Boost level will grant access to more slots.
|
|
12
|
+
* Lottie stickers can only be uploaded on guilds that have either the `VERIFIED` and/or the `PARTNERED` guild feature.
|
|
13
|
+
*
|
|
14
|
+
* @see {@link https://discord.com/developers/docs/resources/sticker#delete-guild-sticker}
|
|
15
|
+
*/
|
|
16
|
+
export async function deleteGuildSticker(bot, guildId, stickerId, reason) {
|
|
17
|
+
return await bot.rest.runMethod(bot.rest, "DELETE", bot.constants.routes.GUILD_STICKER(guildId, stickerId), reason ? { reason } : undefined);
|
|
18
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edit the given sticker.
|
|
3
|
+
*
|
|
4
|
+
* @param bot The bot instance to use to make the request.
|
|
5
|
+
* @param guildId The ID of the guild to get
|
|
6
|
+
* @return A {@link Sticker}
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* Requires the `MANAGE_EMOJIS_AND_STICKERS` permission.
|
|
10
|
+
* Fires a Guild Stickers Update Gateway event.
|
|
11
|
+
*
|
|
12
|
+
* @see {@link https://discord.com/developers/docs/resources/sticker#modify-guild-sticker}
|
|
13
|
+
*/
|
|
14
|
+
export async function editGuildSticker(bot, guildId, stickerId, options) {
|
|
15
|
+
const result = await bot.rest.runMethod(bot.rest, "PATCH", bot.constants.routes.GUILD_STICKER(guildId, stickerId), {
|
|
16
|
+
name: options.name,
|
|
17
|
+
description: options.description,
|
|
18
|
+
tags: options.tags,
|
|
19
|
+
reason: options.reason,
|
|
20
|
+
});
|
|
21
|
+
return bot.transformers.sticker(bot, result);
|
|
22
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a sticker object for the given guild and sticker IDs.
|
|
3
|
+
*
|
|
4
|
+
* @param bot The bot instance to use to make the request.
|
|
5
|
+
* @param guildId The ID of the guild to get
|
|
6
|
+
* @param stickerId The ID of the sticker to get
|
|
7
|
+
* @return A {@link Sticker}
|
|
8
|
+
*
|
|
9
|
+
* @remarks Includes the user field if the bot has the `MANAGE_EMOJIS_AND_STICKERS` permission.
|
|
10
|
+
*
|
|
11
|
+
* @see {@link https://discord.com/developers/docs/resources/sticker#get-guild-sticker}
|
|
12
|
+
*/
|
|
13
|
+
export async function getGuildSticker(bot, guildId, stickerId) {
|
|
14
|
+
const result = await bot.rest.runMethod(bot.rest, "GET", bot.constants.routes.GUILD_STICKER(guildId, stickerId));
|
|
15
|
+
return bot.transformers.sticker(bot, result);
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Collection } from "../../mod.js";
|
|
2
|
+
/**
|
|
3
|
+
* Returns an array of sticker objects for the given guild.
|
|
4
|
+
*
|
|
5
|
+
* @param bot The bot instance to use to make the request.
|
|
6
|
+
* @param guildId The ID of the guild to get
|
|
7
|
+
* @returns A collection of {@link Sticker} objects assorted by sticker ID.
|
|
8
|
+
*
|
|
9
|
+
* @remarks Includes user fields if the bot has the `MANAGE_EMOJIS_AND_STICKERS` permission.
|
|
10
|
+
*
|
|
11
|
+
* @see {@link https://discord.com/developers/docs/resources/sticker#list-guild-stickers}
|
|
12
|
+
*/
|
|
13
|
+
export async function getGuildStickers(bot, guildId) {
|
|
14
|
+
const results = await bot.rest.runMethod(bot.rest, "GET", bot.constants.routes.GUILD_STICKERS(guildId));
|
|
15
|
+
return new Collection(results.map((result) => {
|
|
16
|
+
const pack = bot.transformers.sticker(bot, result);
|
|
17
|
+
return [pack.id, pack];
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a sticker object for the given sticker ID.
|
|
3
|
+
*
|
|
4
|
+
* @param bot The bot instance to use to make the request.
|
|
5
|
+
* @param stickerId The ID of the sticker to get
|
|
6
|
+
* @returns A {@link Sticker}
|
|
7
|
+
*
|
|
8
|
+
* @see {@link https://discord.com/developers/docs/resources/sticker#get-sticker}
|
|
9
|
+
*/
|
|
10
|
+
export async function getSticker(bot, stickerId) {
|
|
11
|
+
const result = await bot.rest.runMethod(bot.rest, "GET", bot.constants.routes.STICKER(stickerId));
|
|
12
|
+
return bot.transformers.sticker(bot, result);
|
|
13
|
+
}
|
|
@@ -14,9 +14,12 @@ import { InteractionResponseTypes } from "../../types/mod.js";
|
|
|
14
14
|
* @see {@link https://discord.com/developers/docs/resources/webhook#edit-webhook-message}
|
|
15
15
|
*/
|
|
16
16
|
export async function editOriginalWebhookMessage(bot, webhookId, token, options) {
|
|
17
|
-
const result = await bot.rest.runMethod(bot.rest, "PATCH", bot.constants.routes.WEBHOOK_MESSAGE_ORIGINAL(webhookId, token, options),
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const result = await bot.rest.runMethod(bot.rest, "PATCH", bot.constants.routes.WEBHOOK_MESSAGE_ORIGINAL(webhookId, token, options), {
|
|
18
|
+
...bot.transformers.reverse.interactionResponse(bot, {
|
|
19
|
+
type: InteractionResponseTypes.UpdateMessage,
|
|
20
|
+
data: options,
|
|
21
|
+
}).data,
|
|
22
|
+
file: options.file,
|
|
23
|
+
});
|
|
21
24
|
return bot.transformers.message(bot, result);
|
|
22
25
|
}
|
|
@@ -15,9 +15,12 @@ import { InteractionResponseTypes } from "../../types/shared.js";
|
|
|
15
15
|
* @see {@link https://discord.com/developers/docs/resources/webhook#edit-webhook-message}
|
|
16
16
|
*/
|
|
17
17
|
export async function editWebhookMessage(bot, webhookId, token, messageId, options) {
|
|
18
|
-
const result = await bot.rest.runMethod(bot.rest, "PATCH", bot.constants.routes.WEBHOOK_MESSAGE(webhookId, token, messageId, options),
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
const result = await bot.rest.runMethod(bot.rest, "PATCH", bot.constants.routes.WEBHOOK_MESSAGE(webhookId, token, messageId, options), {
|
|
19
|
+
...bot.transformers.reverse.interactionResponse(bot, {
|
|
20
|
+
type: InteractionResponseTypes.UpdateMessage,
|
|
21
|
+
data: options,
|
|
22
|
+
}).data,
|
|
23
|
+
file: options.file,
|
|
24
|
+
});
|
|
22
25
|
return bot.transformers.message(bot, result);
|
|
23
26
|
}
|
|
File without changes
|
|
@@ -11,7 +11,7 @@ import { Collection } from "../../util/collection.js";
|
|
|
11
11
|
*
|
|
12
12
|
* @see {@link https://discord.com/developers/docs/resources/webhook#get-guild-webhooks}
|
|
13
13
|
*/
|
|
14
|
-
export async function
|
|
14
|
+
export async function getGuildWebhooks(bot, guildId) {
|
|
15
15
|
const results = await bot.rest.runMethod(bot.rest, "GET", bot.constants.routes.GUILD_WEBHOOKS(guildId));
|
|
16
16
|
return new Collection(results.map((result) => {
|
|
17
17
|
const webhook = bot.transformers.webhook(bot, result);
|
|
@@ -7,7 +7,8 @@ export * from "./editWebhook.js";
|
|
|
7
7
|
export * from "./editWebhookMessage.js";
|
|
8
8
|
export * from "./editWebhookWithToken.js";
|
|
9
9
|
export * from "./executeWebhook.js";
|
|
10
|
+
export * from "./getChannelWebhooks.js";
|
|
11
|
+
export * from "./getGuildWebhooks.js";
|
|
10
12
|
export * from "./getWebhook.js";
|
|
11
13
|
export * from "./getWebhookMessage.js";
|
|
12
|
-
export * from "./getWebhooks.js";
|
|
13
14
|
export * from "./getWebhookWithToken.js";
|
|
@@ -6,6 +6,7 @@ import { integrations } from "./src/integrations/mod.js";
|
|
|
6
6
|
import { members } from "./src/members/mod.js";
|
|
7
7
|
import { messages } from "./src/messages/mod.js";
|
|
8
8
|
import { roles } from "./src/roles/mod.js";
|
|
9
|
+
import { stickers } from "./src/stickers/mod.js";
|
|
9
10
|
import { webhooks } from "./src/webhooks/mod.js";
|
|
10
11
|
// PLUGINS MUST TAKE A BOT ARGUMENT WHICH WILL BE MODIFIED
|
|
11
12
|
export function enablePermissionsPlugin(bot) {
|
|
@@ -22,6 +23,7 @@ export function enablePermissionsPlugin(bot) {
|
|
|
22
23
|
members(bot);
|
|
23
24
|
messages(bot);
|
|
24
25
|
roles(bot);
|
|
26
|
+
stickers(bot);
|
|
25
27
|
webhooks(bot);
|
|
26
28
|
// PLUGINS MUST RETURN THE BOT
|
|
27
29
|
return bot;
|
|
@@ -3,7 +3,7 @@ import { requireBotGuildPermissions } from "../permissions.js";
|
|
|
3
3
|
export function createChannel(bot) {
|
|
4
4
|
const createChannel = bot.helpers.createChannel;
|
|
5
5
|
bot.helpers.createChannel = async function (guildId, options) {
|
|
6
|
-
const guild = bot.guilds.get(guildId);
|
|
6
|
+
const guild = bot.guilds.get(bot.transformers.snowflake(guildId));
|
|
7
7
|
if (guild) {
|
|
8
8
|
if (options?.rateLimitPerUser && !(0 < options.rateLimitPerUser && options.rateLimitPerUser < 21600)) {
|
|
9
9
|
throw new Error("Amount of seconds a user has to wait before sending another message must be between 0-21600");
|
|
@@ -27,7 +27,7 @@ export function createChannel(bot) {
|
|
|
27
27
|
if (options?.userLimit && options.userLimit > 99)
|
|
28
28
|
throw new Error("The user limit must be less than 99.");
|
|
29
29
|
if (options?.parentId) {
|
|
30
|
-
const category = bot.channels.get(options.parentId);
|
|
30
|
+
const category = bot.channels.get(bot.transformers.snowflake(options.parentId));
|
|
31
31
|
if (category && category.type !== ChannelTypes.GuildCategory) {
|
|
32
32
|
throw new Error("The parent id must be for a category channel type.");
|
|
33
33
|
}
|
|
@@ -3,7 +3,7 @@ import { requireBotChannelPermissions } from "../permissions.js";
|
|
|
3
3
|
export function deleteChannel(bot) {
|
|
4
4
|
const deleteChannel = bot.helpers.deleteChannel;
|
|
5
5
|
bot.helpers.deleteChannel = async function (channelId, reason) {
|
|
6
|
-
const channel = bot.channels.get(channelId);
|
|
6
|
+
const channel = bot.channels.get(bot.transformers.snowflake(channelId));
|
|
7
7
|
if (channel?.guildId) {
|
|
8
8
|
const guild = bot.guilds.get(channel.guildId);
|
|
9
9
|
if (!guild)
|
|
@@ -22,7 +22,7 @@ export function deleteChannel(bot) {
|
|
|
22
22
|
perms.push("MANAGE_CHANNELS");
|
|
23
23
|
if (isVoice)
|
|
24
24
|
perms.push("CONNECT");
|
|
25
|
-
requireBotChannelPermissions(bot, channelId, perms);
|
|
25
|
+
requireBotChannelPermissions(bot, bot.transformers.snowflake(channelId), perms);
|
|
26
26
|
}
|
|
27
27
|
return await deleteChannel(channelId, reason);
|
|
28
28
|
};
|
|
@@ -3,13 +3,13 @@ import { requireBotChannelPermissions } from "../permissions.js";
|
|
|
3
3
|
export function deleteChannelPermissionOverride(bot) {
|
|
4
4
|
const deleteChannelPermissionOverride = bot.helpers.deleteChannelPermissionOverride;
|
|
5
5
|
bot.helpers.deleteChannelPermissionOverride = async function (channelId, overwriteId) {
|
|
6
|
-
const channel = bot.channels.get(channelId);
|
|
6
|
+
const channel = bot.channels.get(bot.transformers.snowflake(channelId));
|
|
7
7
|
if (channel?.guildId) {
|
|
8
8
|
const perms = ["VIEW_CHANNEL", "MANAGE_ROLES"];
|
|
9
9
|
const isVoice = [ChannelTypes.GuildVoice, ChannelTypes.GuildStageVoice].includes(channel.type);
|
|
10
10
|
if (isVoice)
|
|
11
11
|
perms.push("CONNECT");
|
|
12
|
-
requireBotChannelPermissions(bot, channelId, perms);
|
|
12
|
+
requireBotChannelPermissions(bot, bot.transformers.snowflake(channelId), perms);
|
|
13
13
|
}
|
|
14
14
|
return await deleteChannelPermissionOverride(channelId, overwriteId);
|
|
15
15
|
};
|
|
@@ -3,7 +3,7 @@ import { requireBotChannelPermissions } from "../permissions.js";
|
|
|
3
3
|
export function editChannel(bot) {
|
|
4
4
|
const editChannel = bot.helpers.editChannel;
|
|
5
5
|
bot.helpers.editChannel = async function (channelId, options) {
|
|
6
|
-
const channel = bot.channels.get(channelId);
|
|
6
|
+
const channel = bot.channels.get(bot.transformers.snowflake(channelId));
|
|
7
7
|
if (channel?.guildId) {
|
|
8
8
|
const guild = bot.guilds.get(channel.guildId);
|
|
9
9
|
if (options.rateLimitPerUser && options.rateLimitPerUser > 21600) {
|
|
@@ -55,7 +55,7 @@ export function editChannel(bot) {
|
|
|
55
55
|
if (options.userLimit && options.userLimit > 99)
|
|
56
56
|
throw new Error("The user limit must be less than 99.");
|
|
57
57
|
if (options.parentId) {
|
|
58
|
-
const category = bot.channels.get(options.parentId);
|
|
58
|
+
const category = bot.channels.get(bot.transformers.snowflake(options.parentId));
|
|
59
59
|
if (category && category.type !== ChannelTypes.GuildCategory) {
|
|
60
60
|
throw new Error("The parent id must be for a category channel type.");
|
|
61
61
|
}
|
|
@@ -3,13 +3,13 @@ import { requireBotChannelPermissions } from "../permissions.js";
|
|
|
3
3
|
export function editChannelPermissionOverrides(bot) {
|
|
4
4
|
const editChannelPermissionOverrides = bot.helpers.editChannelPermissionOverrides;
|
|
5
5
|
bot.helpers.editChannelPermissionOverrides = async function (channelId, overwrite) {
|
|
6
|
-
const channel = bot.channels.get(channelId);
|
|
6
|
+
const channel = bot.channels.get(bot.transformers.snowflake(channelId));
|
|
7
7
|
if (channel?.guildId) {
|
|
8
8
|
const perms = ["VIEW_CHANNEL", "MANAGE_ROLES"];
|
|
9
9
|
const isVoice = [ChannelTypes.GuildVoice, ChannelTypes.GuildStageVoice].includes(channel.type);
|
|
10
10
|
if (isVoice)
|
|
11
11
|
perms.push("CONNECT");
|
|
12
|
-
requireBotChannelPermissions(bot, channelId, perms);
|
|
12
|
+
requireBotChannelPermissions(bot, bot.transformers.snowflake(channelId), perms);
|
|
13
13
|
}
|
|
14
14
|
return await editChannelPermissionOverrides(channelId, overwrite);
|
|
15
15
|
};
|
|
@@ -3,19 +3,19 @@ import { requireBotChannelPermissions } from "../permissions.js";
|
|
|
3
3
|
export function followAnnouncementChannel(bot) {
|
|
4
4
|
const followAnnouncementChannel = bot.helpers.followAnnouncementChannel;
|
|
5
5
|
bot.helpers.followAnnouncementChannel = async function (sourceChannelId, targetChannelId) {
|
|
6
|
-
const sourceChannel = bot.channels.get(sourceChannelId);
|
|
6
|
+
const sourceChannel = bot.channels.get(bot.transformers.snowflake(sourceChannelId));
|
|
7
7
|
if (sourceChannel && sourceChannel.type !== ChannelTypes.GuildAnnouncement) {
|
|
8
8
|
throw new Error("Source channel must be an announcement channel");
|
|
9
9
|
}
|
|
10
|
-
const targetChannel = bot.channels.get(targetChannelId);
|
|
10
|
+
const targetChannel = bot.channels.get(bot.transformers.snowflake(targetChannelId));
|
|
11
11
|
if (targetChannel) {
|
|
12
12
|
const isWebhookParent = [ChannelTypes.GuildAnnouncement, ChannelTypes.GuildText].includes(targetChannel.type);
|
|
13
13
|
if (!isWebhookParent) {
|
|
14
14
|
throw new Error("Target channel must be a text channel or an announcement channel");
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
requireBotChannelPermissions(bot, sourceChannelId, ["VIEW_CHANNEL"]);
|
|
18
|
-
requireBotChannelPermissions(bot, targetChannelId, ["VIEW_CHANNEL", "MANAGE_WEBHOOKS"]);
|
|
17
|
+
requireBotChannelPermissions(bot, bot.transformers.snowflake(sourceChannelId), ["VIEW_CHANNEL"]);
|
|
18
|
+
requireBotChannelPermissions(bot, bot.transformers.snowflake(targetChannelId), ["VIEW_CHANNEL", "MANAGE_WEBHOOKS"]);
|
|
19
19
|
return await followAnnouncementChannel(sourceChannelId, targetChannelId);
|
|
20
20
|
};
|
|
21
21
|
}
|