@zygout/eris 0.19.0 → 0.19.1
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/LICENSE +20 -20
- package/README.md +109 -80
- package/esm.mjs +72 -72
- package/index.d.ts +4407 -4397
- package/index.js +75 -75
- package/lib/Client.js +4708 -4683
- package/lib/Constants.d.ts +990 -988
- package/lib/Constants.js +1163 -1161
- package/lib/command/Command.js +552 -552
- package/lib/command/CommandClient.js +460 -460
- package/lib/errors/DiscordHTTPError.js +63 -63
- package/lib/errors/DiscordRESTError.js +77 -77
- package/lib/gateway/Shard.js +3029 -3029
- package/lib/gateway/ShardManager.js +164 -164
- package/lib/rest/Endpoints.js +172 -172
- package/lib/rest/RequestHandler.js +459 -459
- package/lib/structures/ApplicationCommand.js +125 -125
- package/lib/structures/AutoModerationRule.js +143 -143
- package/lib/structures/AutocompleteInteraction.js +80 -80
- package/lib/structures/Base.js +81 -81
- package/lib/structures/CategoryChannel.js +77 -77
- package/lib/structures/Channel.js +98 -98
- package/lib/structures/CommandInteraction.js +473 -473
- package/lib/structures/ComponentInteraction.js +538 -538
- package/lib/structures/DMChannel.js +278 -278
- package/lib/structures/Entitlement.js +77 -77
- package/lib/structures/ExtendedUser.js +46 -46
- package/lib/structures/ForumChannel.js +24 -24
- package/lib/structures/GroupChannel.js +106 -106
- package/lib/structures/Guild.js +1677 -1677
- package/lib/structures/GuildAuditLogEntry.js +190 -190
- package/lib/structures/GuildChannel.js +128 -128
- package/lib/structures/GuildIntegration.js +99 -99
- package/lib/structures/GuildPreview.js +97 -97
- package/lib/structures/GuildScheduledEvent.js +176 -176
- package/lib/structures/GuildTemplate.js +76 -76
- package/lib/structures/GuildTextableChannel.js +260 -260
- package/lib/structures/Interaction.js +133 -133
- package/lib/structures/Invite.js +143 -143
- package/lib/structures/Lobby.js +108 -108
- package/lib/structures/LobbyMember.js +59 -59
- package/lib/structures/MediaChannel.js +216 -216
- package/lib/structures/Member.js +371 -371
- package/lib/structures/Message.js +708 -708
- package/lib/structures/ModalSubmitInteraction.js +478 -478
- package/lib/structures/NewsChannel.js +34 -34
- package/lib/structures/NewsThreadChannel.js +12 -12
- package/lib/structures/Permission.js +80 -80
- package/lib/structures/PermissionOverwrite.js +32 -32
- package/lib/structures/PingInteraction.js +39 -39
- package/lib/structures/PrivateThreadChannel.js +25 -25
- package/lib/structures/PublicThreadChannel.js +26 -26
- package/lib/structures/Role.js +163 -163
- package/lib/structures/SKU.js +80 -80
- package/lib/structures/SoundboardSound.js +79 -79
- package/lib/structures/StageChannel.js +59 -59
- package/lib/structures/StageInstance.js +55 -55
- package/lib/structures/Subscription.js +69 -69
- package/lib/structures/TextChannel.js +202 -202
- package/lib/structures/ThreadChannel.js +143 -143
- package/lib/structures/ThreadMember.js +59 -59
- package/lib/structures/UnavailableGuild.js +26 -26
- package/lib/structures/UnknownInteraction.js +502 -502
- package/lib/structures/User.js +296 -296
- package/lib/structures/VoiceChannel.js +166 -166
- package/lib/structures/VoiceState.js +84 -84
- package/lib/util/BrowserWebSocket.js +76 -76
- package/lib/util/Bucket.js +89 -89
- package/lib/util/Collection.js +202 -202
- package/lib/util/MultipartData.js +70 -70
- package/lib/util/Opus.js +33 -33
- package/lib/util/SequentialBucket.js +83 -83
- package/lib/util/emitDeprecation.js +26 -26
- package/lib/voice/Piper.js +300 -300
- package/lib/voice/SharedStream.js +238 -238
- package/lib/voice/VoiceConnection.js +1440 -1440
- package/lib/voice/VoiceConnectionManager.js +151 -151
- package/lib/voice/VoiceDataStream.js +22 -22
- package/lib/voice/streams/BaseTransformer.js +40 -40
- package/lib/voice/streams/DCAOpusTransformer.js +78 -78
- package/lib/voice/streams/FFmpegDuplex.js +192 -192
- package/lib/voice/streams/FFmpegOggTransformer.js +35 -35
- package/lib/voice/streams/FFmpegPCMTransformer.js +26 -26
- package/lib/voice/streams/OggOpusTransformer.js +108 -108
- package/lib/voice/streams/PCMOpusTransformer.js +61 -61
- package/lib/voice/streams/VolumeTransformer.js +50 -50
- package/lib/voice/streams/WebmOpusTransformer.js +258 -258
- package/package.json +83 -82
|
@@ -1,190 +1,190 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const Base = require("./Base");
|
|
4
|
-
const Guild = require("./Guild");
|
|
5
|
-
const GuildChannel = require("./GuildChannel");
|
|
6
|
-
const Invite = require("./Invite");
|
|
7
|
-
const { AuditLogActions } = require("../Constants");
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Represents a guild audit log entry describing a moderation action
|
|
11
|
-
* @prop {Number} actionType The action type of the entry. See Constants.AuditLogActions for more details
|
|
12
|
-
* @prop {Object?} after The properties of the targeted object after the action was taken
|
|
13
|
-
* For example, if a channel was renamed from #general to #potato, this would be `{name: "potato"}``
|
|
14
|
-
* @prop {String?} autoModerationRuleName The name of the automod rule that was triggered, action types 143-145 only
|
|
15
|
-
* @prop {Number?} autoModerationRuleTriggerType The trigger type of the automod rule that was triggered, action types 143-145 only
|
|
16
|
-
* @prop {Object?} before The properties of the targeted object before the action was taken
|
|
17
|
-
* For example, if a channel was renamed from #general to #potato, this would be `{name: "general"}``
|
|
18
|
-
* @prop {(CategoryChannel | TextChannel | VoiceChannel | NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel | StageChannel | Object)?} channel The channel targeted in the entry, action types 26 (MEMBER_MOVE), 72/74/75 (MESSAGE_DELETE/PIN/UNPIN) and 83/84/85 (STAGE_INSTANCE_CREATE/UPDATE/DELETE) only. If the channel is not cached, this will be an object with an `id` key. No other property is guaranteed.
|
|
19
|
-
* @prop {Number?} count The number of entities targeted
|
|
20
|
-
* For example, for action type 26 (MEMBER_MOVE), this is the number of members that were moved/disconnected from the voice channel
|
|
21
|
-
* @prop {Number?} deleteMemberDays The number of days of inactivity to prune for, action type 21 (MEMBER_PRUNE) only
|
|
22
|
-
* @prop {Guild | Object} guild The guild containing the entry. If the guild is not cached, this will be an object with an `id` key. No other property is guaranteed.
|
|
23
|
-
* @prop {String} id The ID of the entry
|
|
24
|
-
* @prop {(Member | Object)?} member The member described by the permission overwrite, action types 13-15 (CHANNEL\_OVERWRITE\_CREATE/UPDATE/DELETE) only. If the guild or member is not cached, this could be {id: String}
|
|
25
|
-
* @prop {Number?} membersRemoved The number of members pruned from the server, action type 21 (MEMBER_PRUNE) only
|
|
26
|
-
* @prop {(Message | Object)?} message The message that was (un)pinned, action types 74/75 (MESSAGE_PIN/UNPIN) only. If the channel or message is not cached, this will be an object with an `id` key. No other property is guaranteed.
|
|
27
|
-
* @prop {String?} reason The reason for the action
|
|
28
|
-
* @prop {(Role | Object)?} role The role described by the permission overwrite, action types 13-15 (CHANNEL\_OVERWRITE\_CREATE/UPDATE/DELETE) only. If the guild or role is not cached, this could be {id: String, name: String}
|
|
29
|
-
* @prop {String?} status The new voice channel status, action type 192 (VOICE\_CHANNEL\_STATUS\_UPDATE) only
|
|
30
|
-
* @prop {(CategoryChannel | Guild | Member | Invite | Role | Object | TextChannel | VoiceChannel | NewsChannel)?} target The object of the action target
|
|
31
|
-
* If the item or the item's guild (where relevant, not including invites) is not cached, this property will be null
|
|
32
|
-
* If the action targets a guild, this could be a Guild object
|
|
33
|
-
* If the action targets a guild channel, this could be a CategoryChannel, TextChannel, or VoiceChannel object
|
|
34
|
-
* If the action targets a member, this could be a Member object
|
|
35
|
-
* If the action targets a role, this could be a Role object
|
|
36
|
-
* If the action targets an invite, this is an Invite object
|
|
37
|
-
* If the action targets a webhook, this is null
|
|
38
|
-
* If the action targets a emoji, this could be an emoji object
|
|
39
|
-
* If the action targets a sticker, this could be a sticker object
|
|
40
|
-
* If the action targets a message, this is a User object
|
|
41
|
-
* @prop {String} targetID The ID of the action target
|
|
42
|
-
* @prop {User} user The user that performed the action. If the user is not cached, this will be an object with an `id` key. No other property is guaranteed.
|
|
43
|
-
*/
|
|
44
|
-
class GuildAuditLogEntry extends Base {
|
|
45
|
-
constructor(data, client) {
|
|
46
|
-
super(data.id);
|
|
47
|
-
this._client = client;
|
|
48
|
-
|
|
49
|
-
this.actionType = data.action_type;
|
|
50
|
-
this.guild = client.guilds.get(data.guild_id) || { id: data.guild_id };
|
|
51
|
-
this.reason = data.reason || null;
|
|
52
|
-
this.user = client.users.get(data.user_id);
|
|
53
|
-
this.before = null;
|
|
54
|
-
this.after = null;
|
|
55
|
-
if (data.changes) {
|
|
56
|
-
this.before = {};
|
|
57
|
-
this.after = {};
|
|
58
|
-
data.changes.forEach((change) => {
|
|
59
|
-
if (change.old_value != undefined) {
|
|
60
|
-
this.before[change.key] = change.old_value;
|
|
61
|
-
}
|
|
62
|
-
if (change.new_value != undefined) {
|
|
63
|
-
this.after[change.key] = change.new_value;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (data.target_id) {
|
|
69
|
-
this.targetID = data.target_id;
|
|
70
|
-
}
|
|
71
|
-
if (data.options) {
|
|
72
|
-
if (data.options.count) {
|
|
73
|
-
this.count = +data.options.count;
|
|
74
|
-
}
|
|
75
|
-
if (data.options.channel_id) {
|
|
76
|
-
this.channel = client.getChannel(data.options.channel_id) || { id: data.options.channel_id };
|
|
77
|
-
}
|
|
78
|
-
if (data.options.message_id) {
|
|
79
|
-
if (this.channel instanceof GuildChannel) {
|
|
80
|
-
this.message = this.channel.messages.get(data.options.message_id) || { id: data.options.message_id };
|
|
81
|
-
} else {
|
|
82
|
-
this.message = { id: data.options.message_id };
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
if (data.options.delete_member_days) {
|
|
86
|
-
this.deleteMemberDays = +data.options.delete_member_days;
|
|
87
|
-
this.membersRemoved = +data.options.members_removed;
|
|
88
|
-
}
|
|
89
|
-
if (data.options.type) {
|
|
90
|
-
if (data.options.type === "1") {
|
|
91
|
-
if (this.guild instanceof Guild) {
|
|
92
|
-
this.member = this.guild.members.get(data.options.id) || { id: data.options.id };
|
|
93
|
-
} else {
|
|
94
|
-
this.member = { id: data.options.id };
|
|
95
|
-
}
|
|
96
|
-
} else if (data.options.type === "0") {
|
|
97
|
-
if (this.guild instanceof Guild) {
|
|
98
|
-
this.role = this.guild.roles.get(data.options.id) || {
|
|
99
|
-
id: data.options.id,
|
|
100
|
-
name: data.options.role_name,
|
|
101
|
-
};
|
|
102
|
-
} else {
|
|
103
|
-
this.role = {
|
|
104
|
-
id: data.options.id,
|
|
105
|
-
name: data.options.role_name,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (data.options.status) {
|
|
111
|
-
this.status = data.options.status;
|
|
112
|
-
}
|
|
113
|
-
if (data.options.auto_moderation_rule_name) {
|
|
114
|
-
this.autoModerationRuleName = data.options.auto_moderation_rule_name;
|
|
115
|
-
this.autoModerationRuleTriggerType = +data.options.auto_moderation_rule_trigger_type; // NOTE Discord casts this into a string
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
get target() { // pay more, get less
|
|
121
|
-
const guildAvailable = this.guild instanceof Guild;
|
|
122
|
-
if (this.actionType < 10) { // Guild
|
|
123
|
-
return this.guild;
|
|
124
|
-
} else if (this.actionType < 20 || this.actionType === 192 || this.actionType === 193) { // Channel
|
|
125
|
-
return this._client.getChannel(this.targetID) || null;
|
|
126
|
-
} else if (this.actionType < 30) { // Member
|
|
127
|
-
if (this.actionType === AuditLogActions.MEMBER_MOVE || this.actionType === AuditLogActions.MEMBER_DISCONNECT) { // MEMBER_MOVE / MEMBER_DISCONNECT
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
if (guildAvailable) {
|
|
131
|
-
return this.guild.members.get(this.targetID) || null;
|
|
132
|
-
} else {
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
} else if (this.actionType < 40) { // Role
|
|
136
|
-
if (guildAvailable) {
|
|
137
|
-
return this.guild.roles.get(this.targetID) || null;
|
|
138
|
-
} else {
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
} else if (this.actionType < 50) { // Invite
|
|
142
|
-
const changes = this.actionType === 42 ? this.before : this.after; // Apparently the meaning of life is a deleted invite
|
|
143
|
-
return new Invite({
|
|
144
|
-
code: changes.code,
|
|
145
|
-
channel: changes.channel,
|
|
146
|
-
guild: this.guild,
|
|
147
|
-
uses: changes.uses,
|
|
148
|
-
max_uses: changes.max_uses,
|
|
149
|
-
max_age: changes.max_age,
|
|
150
|
-
temporary: changes.temporary,
|
|
151
|
-
}, this._client);
|
|
152
|
-
} else if (this.actionType < 60) { // Webhook
|
|
153
|
-
return null; // Go get the webhook yourself
|
|
154
|
-
} else if (this.actionType < 70) { // Emoji
|
|
155
|
-
return this.guild && this.guild.emojis.find((emoji) => emoji.id === this.targetID);
|
|
156
|
-
} else if (this.actionType < 80) { // Message
|
|
157
|
-
return this._client.users.get(this.targetID);
|
|
158
|
-
} else if (this.actionType < 83) { // Integrations
|
|
159
|
-
return null;
|
|
160
|
-
} else if (this.actionType < 90) { // Stage Instances
|
|
161
|
-
return this.guild && this.guild.threads.get(this.targetID);
|
|
162
|
-
} else if (this.actionType < 100) { // Sticker
|
|
163
|
-
return this.guild && this.guild.stickers.find((sticker) => sticker.id === this.targetID);
|
|
164
|
-
} else {
|
|
165
|
-
throw new Error("Unrecognized action type: " + this.actionType);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
toJSON(props = []) {
|
|
170
|
-
return super.toJSON([
|
|
171
|
-
"actionType",
|
|
172
|
-
"after",
|
|
173
|
-
"autoModerationRuleName",
|
|
174
|
-
"autoModerationRuleTriggerType",
|
|
175
|
-
"before",
|
|
176
|
-
"channel",
|
|
177
|
-
"count",
|
|
178
|
-
"deleteMemberDays",
|
|
179
|
-
"member",
|
|
180
|
-
"membersRemoved",
|
|
181
|
-
"reason",
|
|
182
|
-
"role",
|
|
183
|
-
"targetID",
|
|
184
|
-
"user",
|
|
185
|
-
...props,
|
|
186
|
-
]);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
module.exports = GuildAuditLogEntry;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Base = require("./Base");
|
|
4
|
+
const Guild = require("./Guild");
|
|
5
|
+
const GuildChannel = require("./GuildChannel");
|
|
6
|
+
const Invite = require("./Invite");
|
|
7
|
+
const { AuditLogActions } = require("../Constants");
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Represents a guild audit log entry describing a moderation action
|
|
11
|
+
* @prop {Number} actionType The action type of the entry. See Constants.AuditLogActions for more details
|
|
12
|
+
* @prop {Object?} after The properties of the targeted object after the action was taken
|
|
13
|
+
* For example, if a channel was renamed from #general to #potato, this would be `{name: "potato"}``
|
|
14
|
+
* @prop {String?} autoModerationRuleName The name of the automod rule that was triggered, action types 143-145 only
|
|
15
|
+
* @prop {Number?} autoModerationRuleTriggerType The trigger type of the automod rule that was triggered, action types 143-145 only
|
|
16
|
+
* @prop {Object?} before The properties of the targeted object before the action was taken
|
|
17
|
+
* For example, if a channel was renamed from #general to #potato, this would be `{name: "general"}``
|
|
18
|
+
* @prop {(CategoryChannel | TextChannel | VoiceChannel | NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel | StageChannel | Object)?} channel The channel targeted in the entry, action types 26 (MEMBER_MOVE), 72/74/75 (MESSAGE_DELETE/PIN/UNPIN) and 83/84/85 (STAGE_INSTANCE_CREATE/UPDATE/DELETE) only. If the channel is not cached, this will be an object with an `id` key. No other property is guaranteed.
|
|
19
|
+
* @prop {Number?} count The number of entities targeted
|
|
20
|
+
* For example, for action type 26 (MEMBER_MOVE), this is the number of members that were moved/disconnected from the voice channel
|
|
21
|
+
* @prop {Number?} deleteMemberDays The number of days of inactivity to prune for, action type 21 (MEMBER_PRUNE) only
|
|
22
|
+
* @prop {Guild | Object} guild The guild containing the entry. If the guild is not cached, this will be an object with an `id` key. No other property is guaranteed.
|
|
23
|
+
* @prop {String} id The ID of the entry
|
|
24
|
+
* @prop {(Member | Object)?} member The member described by the permission overwrite, action types 13-15 (CHANNEL\_OVERWRITE\_CREATE/UPDATE/DELETE) only. If the guild or member is not cached, this could be {id: String}
|
|
25
|
+
* @prop {Number?} membersRemoved The number of members pruned from the server, action type 21 (MEMBER_PRUNE) only
|
|
26
|
+
* @prop {(Message | Object)?} message The message that was (un)pinned, action types 74/75 (MESSAGE_PIN/UNPIN) only. If the channel or message is not cached, this will be an object with an `id` key. No other property is guaranteed.
|
|
27
|
+
* @prop {String?} reason The reason for the action
|
|
28
|
+
* @prop {(Role | Object)?} role The role described by the permission overwrite, action types 13-15 (CHANNEL\_OVERWRITE\_CREATE/UPDATE/DELETE) only. If the guild or role is not cached, this could be {id: String, name: String}
|
|
29
|
+
* @prop {String?} status The new voice channel status, action type 192 (VOICE\_CHANNEL\_STATUS\_UPDATE) only
|
|
30
|
+
* @prop {(CategoryChannel | Guild | Member | Invite | Role | Object | TextChannel | VoiceChannel | NewsChannel)?} target The object of the action target
|
|
31
|
+
* If the item or the item's guild (where relevant, not including invites) is not cached, this property will be null
|
|
32
|
+
* If the action targets a guild, this could be a Guild object
|
|
33
|
+
* If the action targets a guild channel, this could be a CategoryChannel, TextChannel, or VoiceChannel object
|
|
34
|
+
* If the action targets a member, this could be a Member object
|
|
35
|
+
* If the action targets a role, this could be a Role object
|
|
36
|
+
* If the action targets an invite, this is an Invite object
|
|
37
|
+
* If the action targets a webhook, this is null
|
|
38
|
+
* If the action targets a emoji, this could be an emoji object
|
|
39
|
+
* If the action targets a sticker, this could be a sticker object
|
|
40
|
+
* If the action targets a message, this is a User object
|
|
41
|
+
* @prop {String} targetID The ID of the action target
|
|
42
|
+
* @prop {User} user The user that performed the action. If the user is not cached, this will be an object with an `id` key. No other property is guaranteed.
|
|
43
|
+
*/
|
|
44
|
+
class GuildAuditLogEntry extends Base {
|
|
45
|
+
constructor(data, client) {
|
|
46
|
+
super(data.id);
|
|
47
|
+
this._client = client;
|
|
48
|
+
|
|
49
|
+
this.actionType = data.action_type;
|
|
50
|
+
this.guild = client.guilds.get(data.guild_id) || { id: data.guild_id };
|
|
51
|
+
this.reason = data.reason || null;
|
|
52
|
+
this.user = client.users.get(data.user_id);
|
|
53
|
+
this.before = null;
|
|
54
|
+
this.after = null;
|
|
55
|
+
if (data.changes) {
|
|
56
|
+
this.before = {};
|
|
57
|
+
this.after = {};
|
|
58
|
+
data.changes.forEach((change) => {
|
|
59
|
+
if (change.old_value != undefined) {
|
|
60
|
+
this.before[change.key] = change.old_value;
|
|
61
|
+
}
|
|
62
|
+
if (change.new_value != undefined) {
|
|
63
|
+
this.after[change.key] = change.new_value;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (data.target_id) {
|
|
69
|
+
this.targetID = data.target_id;
|
|
70
|
+
}
|
|
71
|
+
if (data.options) {
|
|
72
|
+
if (data.options.count) {
|
|
73
|
+
this.count = +data.options.count;
|
|
74
|
+
}
|
|
75
|
+
if (data.options.channel_id) {
|
|
76
|
+
this.channel = client.getChannel(data.options.channel_id) || { id: data.options.channel_id };
|
|
77
|
+
}
|
|
78
|
+
if (data.options.message_id) {
|
|
79
|
+
if (this.channel instanceof GuildChannel) {
|
|
80
|
+
this.message = this.channel.messages.get(data.options.message_id) || { id: data.options.message_id };
|
|
81
|
+
} else {
|
|
82
|
+
this.message = { id: data.options.message_id };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (data.options.delete_member_days) {
|
|
86
|
+
this.deleteMemberDays = +data.options.delete_member_days;
|
|
87
|
+
this.membersRemoved = +data.options.members_removed;
|
|
88
|
+
}
|
|
89
|
+
if (data.options.type) {
|
|
90
|
+
if (data.options.type === "1") {
|
|
91
|
+
if (this.guild instanceof Guild) {
|
|
92
|
+
this.member = this.guild.members.get(data.options.id) || { id: data.options.id };
|
|
93
|
+
} else {
|
|
94
|
+
this.member = { id: data.options.id };
|
|
95
|
+
}
|
|
96
|
+
} else if (data.options.type === "0") {
|
|
97
|
+
if (this.guild instanceof Guild) {
|
|
98
|
+
this.role = this.guild.roles.get(data.options.id) || {
|
|
99
|
+
id: data.options.id,
|
|
100
|
+
name: data.options.role_name,
|
|
101
|
+
};
|
|
102
|
+
} else {
|
|
103
|
+
this.role = {
|
|
104
|
+
id: data.options.id,
|
|
105
|
+
name: data.options.role_name,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (data.options.status) {
|
|
111
|
+
this.status = data.options.status;
|
|
112
|
+
}
|
|
113
|
+
if (data.options.auto_moderation_rule_name) {
|
|
114
|
+
this.autoModerationRuleName = data.options.auto_moderation_rule_name;
|
|
115
|
+
this.autoModerationRuleTriggerType = +data.options.auto_moderation_rule_trigger_type; // NOTE Discord casts this into a string
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
get target() { // pay more, get less
|
|
121
|
+
const guildAvailable = this.guild instanceof Guild;
|
|
122
|
+
if (this.actionType < 10) { // Guild
|
|
123
|
+
return this.guild;
|
|
124
|
+
} else if (this.actionType < 20 || this.actionType === 192 || this.actionType === 193) { // Channel
|
|
125
|
+
return this._client.getChannel(this.targetID) || null;
|
|
126
|
+
} else if (this.actionType < 30) { // Member
|
|
127
|
+
if (this.actionType === AuditLogActions.MEMBER_MOVE || this.actionType === AuditLogActions.MEMBER_DISCONNECT) { // MEMBER_MOVE / MEMBER_DISCONNECT
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
if (guildAvailable) {
|
|
131
|
+
return this.guild.members.get(this.targetID) || null;
|
|
132
|
+
} else {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
} else if (this.actionType < 40) { // Role
|
|
136
|
+
if (guildAvailable) {
|
|
137
|
+
return this.guild.roles.get(this.targetID) || null;
|
|
138
|
+
} else {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
} else if (this.actionType < 50) { // Invite
|
|
142
|
+
const changes = this.actionType === 42 ? this.before : this.after; // Apparently the meaning of life is a deleted invite
|
|
143
|
+
return new Invite({
|
|
144
|
+
code: changes.code,
|
|
145
|
+
channel: changes.channel,
|
|
146
|
+
guild: this.guild,
|
|
147
|
+
uses: changes.uses,
|
|
148
|
+
max_uses: changes.max_uses,
|
|
149
|
+
max_age: changes.max_age,
|
|
150
|
+
temporary: changes.temporary,
|
|
151
|
+
}, this._client);
|
|
152
|
+
} else if (this.actionType < 60) { // Webhook
|
|
153
|
+
return null; // Go get the webhook yourself
|
|
154
|
+
} else if (this.actionType < 70) { // Emoji
|
|
155
|
+
return this.guild && this.guild.emojis.find((emoji) => emoji.id === this.targetID);
|
|
156
|
+
} else if (this.actionType < 80) { // Message
|
|
157
|
+
return this._client.users.get(this.targetID);
|
|
158
|
+
} else if (this.actionType < 83) { // Integrations
|
|
159
|
+
return null;
|
|
160
|
+
} else if (this.actionType < 90) { // Stage Instances
|
|
161
|
+
return this.guild && this.guild.threads.get(this.targetID);
|
|
162
|
+
} else if (this.actionType < 100) { // Sticker
|
|
163
|
+
return this.guild && this.guild.stickers.find((sticker) => sticker.id === this.targetID);
|
|
164
|
+
} else {
|
|
165
|
+
throw new Error("Unrecognized action type: " + this.actionType);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
toJSON(props = []) {
|
|
170
|
+
return super.toJSON([
|
|
171
|
+
"actionType",
|
|
172
|
+
"after",
|
|
173
|
+
"autoModerationRuleName",
|
|
174
|
+
"autoModerationRuleTriggerType",
|
|
175
|
+
"before",
|
|
176
|
+
"channel",
|
|
177
|
+
"count",
|
|
178
|
+
"deleteMemberDays",
|
|
179
|
+
"member",
|
|
180
|
+
"membersRemoved",
|
|
181
|
+
"reason",
|
|
182
|
+
"role",
|
|
183
|
+
"targetID",
|
|
184
|
+
"user",
|
|
185
|
+
...props,
|
|
186
|
+
]);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
module.exports = GuildAuditLogEntry;
|
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const Channel = require("./Channel");
|
|
4
|
-
const Permission = require("./Permission");
|
|
5
|
-
const { Permissions } = require("../Constants");
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Represents a guild channel. You also probably want to look at CategoryChannel, ForumChannel, NewsChannel, StageChannel, TextChannel, ThreadChannel, and VoiceChannel. See Channel for more properties
|
|
9
|
-
* @extends Channel
|
|
10
|
-
* @prop {Number} flags The channel's flags (see constants). Currently only applies to thread/forum/media channels
|
|
11
|
-
* @prop {Guild} guild The guild that owns the channel
|
|
12
|
-
* @prop {String} name The name of the channel
|
|
13
|
-
* @prop {String?} parentID The ID of the category (or channel for threads) this channel belongs to
|
|
14
|
-
*/
|
|
15
|
-
class GuildChannel extends Channel {
|
|
16
|
-
constructor(data, client) {
|
|
17
|
-
super(data, client);
|
|
18
|
-
this.guild = client.guilds.get(data.guild_id) || {
|
|
19
|
-
id: data.guild_id,
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
this.update(data);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
update(data) {
|
|
26
|
-
if (data.type !== undefined) {
|
|
27
|
-
this.type = data.type;
|
|
28
|
-
}
|
|
29
|
-
if (data.name !== undefined) {
|
|
30
|
-
this.name = data.name;
|
|
31
|
-
}
|
|
32
|
-
if (data.parent_id !== undefined) {
|
|
33
|
-
this.parentID = data.parent_id;
|
|
34
|
-
}
|
|
35
|
-
if (data.flags !== undefined) {
|
|
36
|
-
this.flags = data.flags; // NOTE - Channel flags appear everywhere including in DMs?
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Delete the channel
|
|
42
|
-
* @arg {String} [reason] The reason to be displayed in audit logs
|
|
43
|
-
* @returns {Promise<CategoryChannel | ForumChannel | NewsChannel | NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel | TextChannel | VoiceChannel>}
|
|
44
|
-
*/
|
|
45
|
-
delete(reason) {
|
|
46
|
-
return this._client.deleteChannel.call(this._client, this.id, reason);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Edit the channel's properties
|
|
51
|
-
* @arg {Object} options The properties to edit
|
|
52
|
-
* @arg {Array<String>} [options.appliedTags] [Th] The tags applied to a forum/media thread
|
|
53
|
-
* @arg {Boolean} [options.archived] [Th] The archive status of the channel
|
|
54
|
-
* @arg {Number} [options.autoArchiveDuration] [Th] The duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080
|
|
55
|
-
* @arg {Array<Object>} [options.availableTags] [FM] An array of [tags](https://discord.dev/resources/channel#forum-tag-object) that can be applied. This will overwrite all existing tags unless edited by specifying the tag ID
|
|
56
|
-
* @arg {Number?} [options.bitrate] [VS] The bitrate of the channel
|
|
57
|
-
* @arg {Number?} [options.defaultAutoArchiveDuration] [TAFM] The default duration of newly created threads in minutes to automatically archive the thread after inactivity (60, 1440, 4320, 10080)
|
|
58
|
-
* @arg {Number} [options.defaultForumLayout] [F] The default post [layout type](https://discord.dev/resources/channel#channel-object-forum-layout-types)
|
|
59
|
-
* @arg {Object?} [options.defaultReactionEmoji] [FM] The [emoji](https://discord.dev/resources/channel#default-reaction-object) to show in the Add Reaction Button
|
|
60
|
-
* @arg {Number?} [options.defaultSortOrder] [FM] The default post sort type (0 for latest activity, 1 for creation date)
|
|
61
|
-
* @arg {Number} [options.defaultThreadRateLimitPerUser] [TFM] The default rate limit duration for newly created threads
|
|
62
|
-
* @arg {Number} [options.flags] [FM/Th] The channel's flag [bit set](https://discord.dev/resources/channel#channel-object-channel-flags)
|
|
63
|
-
* @arg {Boolean} [options.invitable] [Th] Whether non-moderators can add other non-moderators to the channel
|
|
64
|
-
* @arg {Boolean} [options.locked] [Th] The lock status of the channel
|
|
65
|
-
* @arg {String} [options.name] [All/Th] The name of the channel
|
|
66
|
-
* @arg {Boolean?} [options.nsfw] [TVASFM] The NSFW status of the channel
|
|
67
|
-
* @arg {String?} [options.parentID] [TVASFM] The ID of the parent channel category for this channel
|
|
68
|
-
* @arg {Array<Object>?} [options.permissionOverwrites] [All] An object containing [permission overwrite](https://discord.dev/resources/channel#overwrite-object) objects
|
|
69
|
-
* @arg {Number?} [options.position] [All] The sorting position of the channel
|
|
70
|
-
* @arg {Number?} [options.rateLimitPerUser] [TVSFM/Th] The time in seconds a user has to wait before sending another message (does not affect bots or users with manageMessages/manageChannel permissions)
|
|
71
|
-
* @arg {String?} [options.rtcRegion] [VS] The RTC region ID of the channel (automatic if `null`)
|
|
72
|
-
* @arg {String?} [options.topic] [TAFM] The topic of the channel
|
|
73
|
-
* @arg {Boolean} [options.type] [TA] The type of channel (only between types 0 and 5)
|
|
74
|
-
* @arg {Number?} [options.userLimit] [VS] The channel user limit
|
|
75
|
-
* @arg {Number?} [options.videoQualityMode] [VS] The camera video quality mode of the channel. `1` is auto, `2` is 720p
|
|
76
|
-
* @arg {String} [reason] The reason to be displayed in audit logs
|
|
77
|
-
* @returns {Promise<CategoryChannel | ForumChannel | NewsChannel | NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel | TextChannel | VoiceChannel>}
|
|
78
|
-
*/
|
|
79
|
-
edit(options, reason) {
|
|
80
|
-
return this._client.editChannel.call(this._client, this.id, options, reason);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Get the channel-specific permissions of a member
|
|
85
|
-
* @arg {String | Member | Object} memberID The ID of the member or a Member object
|
|
86
|
-
* @returns {Permission}
|
|
87
|
-
*/
|
|
88
|
-
permissionsOf(memberID) {
|
|
89
|
-
const member = typeof memberID === "string" ? this.guild.members.get(memberID) : memberID;
|
|
90
|
-
let permission = this.guild.permissionsOf(member).allow;
|
|
91
|
-
if (permission & Permissions.administrator) {
|
|
92
|
-
return new Permission(Permissions.all);
|
|
93
|
-
}
|
|
94
|
-
const channel = this instanceof ThreadChannel ? this.guild.channels.get(this.parentID) : this;
|
|
95
|
-
let overwrite = channel && channel.permissionOverwrites.get(this.guild.id);
|
|
96
|
-
if (overwrite) {
|
|
97
|
-
permission = (permission & ~overwrite.deny) | overwrite.allow;
|
|
98
|
-
}
|
|
99
|
-
let deny = 0n;
|
|
100
|
-
let allow = 0n;
|
|
101
|
-
for (const roleID of member.roles) {
|
|
102
|
-
if ((overwrite = channel && channel.permissionOverwrites.get(roleID))) {
|
|
103
|
-
deny |= overwrite.deny;
|
|
104
|
-
allow |= overwrite.allow;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
permission = (permission & ~deny) | allow;
|
|
108
|
-
overwrite = channel && channel.permissionOverwrites.get(member.id);
|
|
109
|
-
if (overwrite) {
|
|
110
|
-
permission = (permission & ~overwrite.deny) | overwrite.allow;
|
|
111
|
-
}
|
|
112
|
-
return new Permission(permission);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
toJSON(props = []) {
|
|
116
|
-
return super.toJSON([
|
|
117
|
-
"flags",
|
|
118
|
-
"name",
|
|
119
|
-
"parentID",
|
|
120
|
-
"type",
|
|
121
|
-
...props,
|
|
122
|
-
]);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
module.exports = GuildChannel;
|
|
127
|
-
|
|
128
|
-
const ThreadChannel = require("./ThreadChannel");
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Channel = require("./Channel");
|
|
4
|
+
const Permission = require("./Permission");
|
|
5
|
+
const { Permissions } = require("../Constants");
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents a guild channel. You also probably want to look at CategoryChannel, ForumChannel, NewsChannel, StageChannel, TextChannel, ThreadChannel, and VoiceChannel. See Channel for more properties
|
|
9
|
+
* @extends Channel
|
|
10
|
+
* @prop {Number} flags The channel's flags (see constants). Currently only applies to thread/forum/media channels
|
|
11
|
+
* @prop {Guild} guild The guild that owns the channel
|
|
12
|
+
* @prop {String} name The name of the channel
|
|
13
|
+
* @prop {String?} parentID The ID of the category (or channel for threads) this channel belongs to
|
|
14
|
+
*/
|
|
15
|
+
class GuildChannel extends Channel {
|
|
16
|
+
constructor(data, client) {
|
|
17
|
+
super(data, client);
|
|
18
|
+
this.guild = client.guilds.get(data.guild_id) || {
|
|
19
|
+
id: data.guild_id,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
this.update(data);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
update(data) {
|
|
26
|
+
if (data.type !== undefined) {
|
|
27
|
+
this.type = data.type;
|
|
28
|
+
}
|
|
29
|
+
if (data.name !== undefined) {
|
|
30
|
+
this.name = data.name;
|
|
31
|
+
}
|
|
32
|
+
if (data.parent_id !== undefined) {
|
|
33
|
+
this.parentID = data.parent_id;
|
|
34
|
+
}
|
|
35
|
+
if (data.flags !== undefined) {
|
|
36
|
+
this.flags = data.flags; // NOTE - Channel flags appear everywhere including in DMs?
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Delete the channel
|
|
42
|
+
* @arg {String} [reason] The reason to be displayed in audit logs
|
|
43
|
+
* @returns {Promise<CategoryChannel | ForumChannel | NewsChannel | NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel | TextChannel | VoiceChannel>}
|
|
44
|
+
*/
|
|
45
|
+
delete(reason) {
|
|
46
|
+
return this._client.deleteChannel.call(this._client, this.id, reason);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Edit the channel's properties
|
|
51
|
+
* @arg {Object} options The properties to edit
|
|
52
|
+
* @arg {Array<String>} [options.appliedTags] [Th] The tags applied to a forum/media thread
|
|
53
|
+
* @arg {Boolean} [options.archived] [Th] The archive status of the channel
|
|
54
|
+
* @arg {Number} [options.autoArchiveDuration] [Th] The duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080
|
|
55
|
+
* @arg {Array<Object>} [options.availableTags] [FM] An array of [tags](https://discord.dev/resources/channel#forum-tag-object) that can be applied. This will overwrite all existing tags unless edited by specifying the tag ID
|
|
56
|
+
* @arg {Number?} [options.bitrate] [VS] The bitrate of the channel
|
|
57
|
+
* @arg {Number?} [options.defaultAutoArchiveDuration] [TAFM] The default duration of newly created threads in minutes to automatically archive the thread after inactivity (60, 1440, 4320, 10080)
|
|
58
|
+
* @arg {Number} [options.defaultForumLayout] [F] The default post [layout type](https://discord.dev/resources/channel#channel-object-forum-layout-types)
|
|
59
|
+
* @arg {Object?} [options.defaultReactionEmoji] [FM] The [emoji](https://discord.dev/resources/channel#default-reaction-object) to show in the Add Reaction Button
|
|
60
|
+
* @arg {Number?} [options.defaultSortOrder] [FM] The default post sort type (0 for latest activity, 1 for creation date)
|
|
61
|
+
* @arg {Number} [options.defaultThreadRateLimitPerUser] [TFM] The default rate limit duration for newly created threads
|
|
62
|
+
* @arg {Number} [options.flags] [FM/Th] The channel's flag [bit set](https://discord.dev/resources/channel#channel-object-channel-flags)
|
|
63
|
+
* @arg {Boolean} [options.invitable] [Th] Whether non-moderators can add other non-moderators to the channel
|
|
64
|
+
* @arg {Boolean} [options.locked] [Th] The lock status of the channel
|
|
65
|
+
* @arg {String} [options.name] [All/Th] The name of the channel
|
|
66
|
+
* @arg {Boolean?} [options.nsfw] [TVASFM] The NSFW status of the channel
|
|
67
|
+
* @arg {String?} [options.parentID] [TVASFM] The ID of the parent channel category for this channel
|
|
68
|
+
* @arg {Array<Object>?} [options.permissionOverwrites] [All] An object containing [permission overwrite](https://discord.dev/resources/channel#overwrite-object) objects
|
|
69
|
+
* @arg {Number?} [options.position] [All] The sorting position of the channel
|
|
70
|
+
* @arg {Number?} [options.rateLimitPerUser] [TVSFM/Th] The time in seconds a user has to wait before sending another message (does not affect bots or users with manageMessages/manageChannel permissions)
|
|
71
|
+
* @arg {String?} [options.rtcRegion] [VS] The RTC region ID of the channel (automatic if `null`)
|
|
72
|
+
* @arg {String?} [options.topic] [TAFM] The topic of the channel
|
|
73
|
+
* @arg {Boolean} [options.type] [TA] The type of channel (only between types 0 and 5)
|
|
74
|
+
* @arg {Number?} [options.userLimit] [VS] The channel user limit
|
|
75
|
+
* @arg {Number?} [options.videoQualityMode] [VS] The camera video quality mode of the channel. `1` is auto, `2` is 720p
|
|
76
|
+
* @arg {String} [reason] The reason to be displayed in audit logs
|
|
77
|
+
* @returns {Promise<CategoryChannel | ForumChannel | NewsChannel | NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel | TextChannel | VoiceChannel>}
|
|
78
|
+
*/
|
|
79
|
+
edit(options, reason) {
|
|
80
|
+
return this._client.editChannel.call(this._client, this.id, options, reason);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Get the channel-specific permissions of a member
|
|
85
|
+
* @arg {String | Member | Object} memberID The ID of the member or a Member object
|
|
86
|
+
* @returns {Permission}
|
|
87
|
+
*/
|
|
88
|
+
permissionsOf(memberID) {
|
|
89
|
+
const member = typeof memberID === "string" ? this.guild.members.get(memberID) : memberID;
|
|
90
|
+
let permission = this.guild.permissionsOf(member).allow;
|
|
91
|
+
if (permission & Permissions.administrator) {
|
|
92
|
+
return new Permission(Permissions.all);
|
|
93
|
+
}
|
|
94
|
+
const channel = this instanceof ThreadChannel ? this.guild.channels.get(this.parentID) : this;
|
|
95
|
+
let overwrite = channel && channel.permissionOverwrites.get(this.guild.id);
|
|
96
|
+
if (overwrite) {
|
|
97
|
+
permission = (permission & ~overwrite.deny) | overwrite.allow;
|
|
98
|
+
}
|
|
99
|
+
let deny = 0n;
|
|
100
|
+
let allow = 0n;
|
|
101
|
+
for (const roleID of member.roles) {
|
|
102
|
+
if ((overwrite = channel && channel.permissionOverwrites.get(roleID))) {
|
|
103
|
+
deny |= overwrite.deny;
|
|
104
|
+
allow |= overwrite.allow;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
permission = (permission & ~deny) | allow;
|
|
108
|
+
overwrite = channel && channel.permissionOverwrites.get(member.id);
|
|
109
|
+
if (overwrite) {
|
|
110
|
+
permission = (permission & ~overwrite.deny) | overwrite.allow;
|
|
111
|
+
}
|
|
112
|
+
return new Permission(permission);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
toJSON(props = []) {
|
|
116
|
+
return super.toJSON([
|
|
117
|
+
"flags",
|
|
118
|
+
"name",
|
|
119
|
+
"parentID",
|
|
120
|
+
"type",
|
|
121
|
+
...props,
|
|
122
|
+
]);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
module.exports = GuildChannel;
|
|
127
|
+
|
|
128
|
+
const ThreadChannel = require("./ThreadChannel");
|