Add files via upload
This commit is contained in:
93
node_modules/eris/lib/structures/AutocompleteInteraction.js
generated
vendored
Normal file
93
node_modules/eris/lib/structures/AutocompleteInteraction.js
generated
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
"use strict";
|
||||
|
||||
const Interaction = require("./Interaction");
|
||||
const Member = require("./Member");
|
||||
const Permission = require("./Permission");
|
||||
const {InteractionResponseTypes} = require("../Constants");
|
||||
|
||||
/**
|
||||
* Represents an application command autocomplete interaction. See Interaction for more properties.
|
||||
* @extends Interaction
|
||||
* @prop {Permission?} appPermissions The permissions the app or bot has within the channel the interaction was sent from
|
||||
* @prop {PrivateChannel | TextChannel | NewsChannel} channel The channel the interaction was created in. Can be partial with only the id if the channel is not cached.
|
||||
* @prop {Object} data The data attached to the interaction
|
||||
* @prop {String} data.id The ID of the Application Command
|
||||
* @prop {String} data.name The command name
|
||||
* @prop {Number} data.type The [command type](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types)
|
||||
* @prop {String?} data.target_id The id the of user or message targetted by a context menu command
|
||||
* @prop {Array<Object>?} data.options The run Application Command options
|
||||
* @prop {String} data.options[].name The name of the Application Command option
|
||||
* @prop {Number} data.options[].type Command option type, 1-10
|
||||
* @prop {(String | Number | Boolean)?} data.options[].value The value of the run Application Command (Mutually exclusive with options)
|
||||
* @prop {Boolean?} data.options[].focused Whether or not the option is focused
|
||||
* @prop {Array<Object>?} data.options[].options The run Application Command options (Mutually exclusive with value)
|
||||
* @prop {String?} guildID The ID of the guild in which the interaction was created
|
||||
* @prop {Member?} member The member who triggered the interaction (This is only sent when the interaction is invoked within a guild)
|
||||
* @prop {User?} user The user who triggered the interaction (This is only sent when the interaction is invoked within a dm)
|
||||
*/
|
||||
class AutocompleteInteraction extends Interaction {
|
||||
constructor(info, client) {
|
||||
super(info, client);
|
||||
|
||||
this.channel = this._client.getChannel(info.channel_id) || {
|
||||
id: info.channel_id
|
||||
};
|
||||
|
||||
this.data = info.data;
|
||||
|
||||
if(info.guild_id !== undefined) {
|
||||
this.guildID = info.guild_id;
|
||||
}
|
||||
|
||||
if(info.member !== undefined) {
|
||||
if(this.channel.guild) {
|
||||
info.member.id = info.member.user.id;
|
||||
this.member = this.channel.guild.members.update(info.member, this.channel.guild);
|
||||
} else {
|
||||
const guild = this._client.guilds.get(info.guild_id);
|
||||
this.member = new Member(info.member, guild, this._client);
|
||||
}
|
||||
}
|
||||
|
||||
if(info.user !== undefined) {
|
||||
this.user = this._client.users.update(info.user, client);
|
||||
}
|
||||
|
||||
if(info.app_permissions !== undefined) {
|
||||
this.appPermissions = new Permission(info.app_permissions);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Acknowledges the autocomplete interaction with a result of choices.
|
||||
* Note: You can **not** use more than 1 initial interaction response per interaction.
|
||||
* @arg {Array<Object>} choices The autocomplete choices to return to the user
|
||||
* @arg {String | Number} choices[].name The choice display name
|
||||
* @arg {String} choices[].value The choice value to return to the bot
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async acknowledge(choices) {
|
||||
return this.result(choices);
|
||||
}
|
||||
|
||||
/**
|
||||
* Acknowledges the autocomplete interaction with a result of choices.
|
||||
* Note: You can **not** use more than 1 initial interaction response per interaction.
|
||||
* @arg {Array<Object>} choices The autocomplete choices to return to the user
|
||||
* @arg {String | Number} choices[].name The choice display name
|
||||
* @arg {String} choices[].value The choice value to return to the bot
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async result(choices) {
|
||||
if(this.acknowledged === true) {
|
||||
throw new Error("You have already acknowledged this interaction.");
|
||||
}
|
||||
return this._client.createInteractionResponse.call(this._client, this.id, this.token, {
|
||||
type: InteractionResponseTypes.APPLICATION_COMMAND_AUTOCOMPLETE_RESULT,
|
||||
data: {choices}
|
||||
}).then(() => this.update());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = AutocompleteInteraction;
|
81
node_modules/eris/lib/structures/Base.js
generated
vendored
Normal file
81
node_modules/eris/lib/structures/Base.js
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
"use strict";
|
||||
|
||||
const util = require("util");
|
||||
|
||||
/**
|
||||
* Provides utilities for working with many Discord structures
|
||||
* @prop {string} id A Discord snowflake identifying the object
|
||||
* @prop {Number} createdAt Timestamp of structure creation
|
||||
*/
|
||||
class Base {
|
||||
constructor(id) {
|
||||
if(id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
get createdAt() {
|
||||
return Base.getCreatedAt(this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the timestamp in milliseconds associated with a Discord ID/snowflake
|
||||
* @param {String} id The ID of a structure
|
||||
* @returns {Number}
|
||||
*/
|
||||
static getCreatedAt(id) {
|
||||
return Base.getDiscordEpoch(id) + 1420070400000;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of milliseconds since epoch represented by an ID/snowflake
|
||||
* @param {string} id The ID of a structure
|
||||
* @returns {number}
|
||||
*/
|
||||
static getDiscordEpoch(id) {
|
||||
return Math.floor(id / 4194304);
|
||||
}
|
||||
|
||||
[util.inspect.custom]() {
|
||||
// http://stackoverflow.com/questions/5905492/dynamic-function-name-in-javascript
|
||||
const copy = new {[this.constructor.name]: class {}}[this.constructor.name]();
|
||||
for(const key in this) {
|
||||
if(this.hasOwnProperty(key) && !key.startsWith("_") && this[key] !== undefined) {
|
||||
copy[key] = this[key];
|
||||
}
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
toString() {
|
||||
return `[${this.constructor.name} ${this.id}]`;
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
const json = {};
|
||||
if(this.id) {
|
||||
json.id = this.id;
|
||||
json.createdAt = this.createdAt;
|
||||
}
|
||||
for(const prop of props) {
|
||||
const value = this[prop];
|
||||
const type = typeof value;
|
||||
if(value === undefined) {
|
||||
continue;
|
||||
} else if(type !== "object" && type !== "function" && type !== "bigint" || value === null) {
|
||||
json[prop] = value;
|
||||
} else if(value.toJSON !== undefined) {
|
||||
json[prop] = value.toJSON();
|
||||
} else if(value.values !== undefined) {
|
||||
json[prop] = [...value.values()];
|
||||
} else if(type === "bigint") {
|
||||
json[prop] = value.toString();
|
||||
} else if(type === "object") {
|
||||
json[prop] = value;
|
||||
}
|
||||
}
|
||||
return json;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Base;
|
76
node_modules/eris/lib/structures/Call.js
generated
vendored
Normal file
76
node_modules/eris/lib/structures/Call.js
generated
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
"use strict";
|
||||
|
||||
const Base = require("./Base");
|
||||
const Collection = require("../util/Collection");
|
||||
const VoiceState = require("./VoiceState");
|
||||
|
||||
/**
|
||||
* Represents a call
|
||||
* @prop {GroupChannel} channel The call channel
|
||||
* @prop {Number} createdAt Timestamp of the call's creation
|
||||
* @prop {Number?} endedTimestamp The timestamp of the call end
|
||||
* @prop {String} id The ID of the call
|
||||
* @prop {Array<String>} participants The IDs of the call participants
|
||||
* @prop {String?} region The region of the call server
|
||||
* @prop {Array<String>?} ringing The IDs of people that still have not responded to the call request
|
||||
* @prop {Boolean} unavailable Whether the call is unavailable or not
|
||||
* @prop {Collection<VoiceState>} voiceStates The voice states of the call participants
|
||||
*/
|
||||
class Call extends Base {
|
||||
constructor(data, channel) {
|
||||
super(data.id);
|
||||
this.channel = channel;
|
||||
this.voiceStates = new Collection(VoiceState);
|
||||
this.ringing = [];
|
||||
this.participants = [];
|
||||
this.region = null;
|
||||
this.endedTimestamp = null;
|
||||
this.unavailable = true;
|
||||
this.update(data);
|
||||
}
|
||||
|
||||
update(data) {
|
||||
if(data.participants !== undefined) {
|
||||
this.participants = data.participants;
|
||||
}
|
||||
if(data.ringing !== undefined) {
|
||||
if(!this.ringing.includes(this.channel._client.user.id) && (this.ringing = data.ringing).includes(this.channel._client.user.id)) {
|
||||
/**
|
||||
* Fired when the bot user is rung in a call
|
||||
* @event Client#callRing
|
||||
* @prop {Call} call The call
|
||||
*/
|
||||
this.channel._client.emit("callRing", this);
|
||||
}
|
||||
}
|
||||
if(data.region !== undefined) {
|
||||
this.region = data.region;
|
||||
}
|
||||
if(data.ended_timestamp !== undefined) {
|
||||
this.endedTimestamp = Date.parse(data.ended_timestamp);
|
||||
}
|
||||
if(data.unavailable !== undefined) {
|
||||
this.unavailable = data.unavailable;
|
||||
}
|
||||
if(data.voice_states) {
|
||||
data.voice_states.forEach((voiceState) => {
|
||||
voiceState.id = voiceState.user_id;
|
||||
this.voiceStates.add(voiceState);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"endedTimestamp",
|
||||
"participants",
|
||||
"region",
|
||||
"ringing",
|
||||
"unavailable",
|
||||
"voiceStates",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Call;
|
25
node_modules/eris/lib/structures/CategoryChannel.js
generated
vendored
Normal file
25
node_modules/eris/lib/structures/CategoryChannel.js
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
|
||||
const Collection = require("../util/Collection");
|
||||
const GuildChannel = require("./GuildChannel");
|
||||
|
||||
/**
|
||||
* Represents a guild category channel. See GuildChannel for more properties and methods.
|
||||
* @extends GuildChannel
|
||||
* @prop {Collection<GuildChannel>} channels A collection of guild channels that are part of this category
|
||||
*/
|
||||
class CategoryChannel extends GuildChannel {
|
||||
get channels() {
|
||||
const channels = new Collection(GuildChannel);
|
||||
if(this.guild && this.guild.channels) {
|
||||
for(const channel of this.guild.channels.values()) {
|
||||
if(channel.parentID === this.id) {
|
||||
channels.add(channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
return channels;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CategoryChannel;
|
95
node_modules/eris/lib/structures/Channel.js
generated
vendored
Normal file
95
node_modules/eris/lib/structures/Channel.js
generated
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
"use strict";
|
||||
|
||||
const Base = require("./Base");
|
||||
const {ChannelTypes} = require("../Constants");
|
||||
|
||||
/**
|
||||
* Represents a channel. You also probably want to look at CategoryChannel, GroupChannel, NewsChannel, PrivateChannel, TextChannel, and TextVoiceChannel.
|
||||
* @prop {Client} client The client that initialized the channel
|
||||
* @prop {Number} createdAt Timestamp of the channel's creation
|
||||
* @prop {String} id The ID of the channel
|
||||
* @prop {String} mention A string that mentions the channel
|
||||
* @prop {Number} type The type of the channel
|
||||
*/
|
||||
class Channel extends Base {
|
||||
constructor(data, client) {
|
||||
super(data.id);
|
||||
this.type = data.type;
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
get mention() {
|
||||
return `<#${this.id}>`;
|
||||
}
|
||||
|
||||
static from(data, client) {
|
||||
switch(data.type) {
|
||||
case ChannelTypes.GUILD_TEXT: {
|
||||
return new TextChannel(data, client);
|
||||
}
|
||||
case ChannelTypes.DM: {
|
||||
return new PrivateChannel(data, client);
|
||||
}
|
||||
case ChannelTypes.GUILD_VOICE: {
|
||||
return new TextVoiceChannel(data, client);
|
||||
}
|
||||
case ChannelTypes.GROUP_DM: {
|
||||
return new GroupChannel(data, client);
|
||||
}
|
||||
case ChannelTypes.GUILD_CATEGORY: {
|
||||
return new CategoryChannel(data, client);
|
||||
}
|
||||
case ChannelTypes.GUILD_NEWS: {
|
||||
return new NewsChannel(data, client);
|
||||
}
|
||||
case ChannelTypes.GUILD_STORE: {
|
||||
return new StoreChannel(data, client);
|
||||
}
|
||||
case ChannelTypes.GUILD_NEWS_THREAD: {
|
||||
return new NewsThreadChannel(data, client);
|
||||
}
|
||||
case ChannelTypes.GUILD_PUBLIC_THREAD: {
|
||||
return new PublicThreadChannel(data, client);
|
||||
}
|
||||
case ChannelTypes.GUILD_PRIVATE_THREAD: {
|
||||
return new PrivateThreadChannel(data, client);
|
||||
}
|
||||
case ChannelTypes.GUILD_STAGE_VOICE: {
|
||||
return new StageChannel(data, client);
|
||||
}
|
||||
}
|
||||
if(data.guild_id) {
|
||||
if(data.last_message_id !== undefined) {
|
||||
client.emit("warn", new Error(`Unknown guild text channel type: ${data.type}\n${JSON.stringify(data)}`));
|
||||
return new TextChannel(data, client);
|
||||
}
|
||||
client.emit("warn", new Error(`Unknown guild channel type: ${data.type}\n${JSON.stringify(data)}`));
|
||||
return new GuildChannel(data, client);
|
||||
}
|
||||
client.emit("warn", new Error(`Unknown channel type: ${data.type}\n${JSON.stringify(data)}`));
|
||||
return new Channel(data, client);
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"type",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Channel;
|
||||
|
||||
// Circular import
|
||||
const CategoryChannel = require("./CategoryChannel");
|
||||
const GuildChannel = require("./GuildChannel");
|
||||
const GroupChannel = require("./GroupChannel");
|
||||
const NewsChannel = require("./NewsChannel");
|
||||
const NewsThreadChannel = require("./NewsThreadChannel");
|
||||
const PrivateChannel = require("./PrivateChannel");
|
||||
const PrivateThreadChannel = require("./PrivateThreadChannel");
|
||||
const PublicThreadChannel = require("./PublicThreadChannel");
|
||||
const StageChannel = require("./StageChannel");
|
||||
const StoreChannel = require("./StoreChannel");
|
||||
const TextChannel = require("./TextChannel");
|
||||
const TextVoiceChannel = require("./TextVoiceChannel");
|
406
node_modules/eris/lib/structures/CommandInteraction.js
generated
vendored
Normal file
406
node_modules/eris/lib/structures/CommandInteraction.js
generated
vendored
Normal file
@ -0,0 +1,406 @@
|
||||
"use strict";
|
||||
|
||||
const Interaction = require("./Interaction");
|
||||
const Member = require("./Member");
|
||||
const User = require("./User");
|
||||
const Role = require("./Role");
|
||||
const Channel = require("./Channel");
|
||||
const Message = require("./Message");
|
||||
const Collection = require("../util/Collection");
|
||||
const Permission = require("./Permission");
|
||||
|
||||
const {InteractionResponseTypes} = require("../Constants");
|
||||
|
||||
/**
|
||||
* Represents an application command interaction. See Interaction for more properties.
|
||||
* @extends Interaction
|
||||
* @prop {Permission?} appPermissions The permissions the app or bot has within the channel the interaction was sent from
|
||||
* @prop {PrivateChannel | TextChannel | NewsChannel} channel The channel the interaction was created in. Can be partial with only the id if the channel is not cached.
|
||||
* @prop {Object} data The data attached to the interaction
|
||||
* @prop {String} data.id The ID of the Application Command
|
||||
* @prop {String} data.name The command name
|
||||
* @prop {Number} data.type The [command type](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types)
|
||||
* @prop {String?} data.target_id The id the of user or message targetted by a context menu command
|
||||
* @prop {Array<Object>?} data.options The run Application Command options
|
||||
* @prop {String} data.options[].name The name of the Application Command option
|
||||
* @prop {Number} data.options[].type Command option type, 1-10
|
||||
* @prop {(String | Number | Boolean)?} data.options[].value The value of the run Application Command (Mutually exclusive with options)
|
||||
* @prop {Array<Object>?} data.options[].options The run Application Command options (Mutually exclusive with value)
|
||||
* @prop {Object?} data.resolved converted users + roles + channels
|
||||
* @prop {Collection<User>?} data.resolved.users converted users
|
||||
* @prop {Collection<Member>?} data.resolved.members converted members
|
||||
* @prop {Collection<Role>?} data.resolved.roles converted roles
|
||||
* @prop {Collection<Channel>?} data.resolved.channels converted channels
|
||||
* @prop {String?} guildID The ID of the guild in which the interaction was created
|
||||
* @prop {Member?} member The member who triggered the interaction (This is only sent when the interaction is invoked within a guild)
|
||||
* @prop {User?} user The user who triggered the interaction (This is only sent when the interaction is invoked within a dm)
|
||||
*/
|
||||
class CommandInteraction extends Interaction {
|
||||
constructor(info, client) {
|
||||
super(info, client);
|
||||
|
||||
this.channel = this._client.getChannel(info.channel_id) || {
|
||||
id: info.channel_id
|
||||
};
|
||||
|
||||
this.data = JSON.parse(JSON.stringify(info.data));
|
||||
|
||||
if(info.data.resolved !== undefined) {
|
||||
//Users
|
||||
if(info.data.resolved.users !== undefined) {
|
||||
const usermap = new Collection(User);
|
||||
Object.entries(info.data.resolved.users).forEach(([id, user]) => {
|
||||
usermap.set(id, this._client.users.update(user, client));
|
||||
});
|
||||
this.data.resolved.users = usermap;
|
||||
}
|
||||
//Members
|
||||
if(info.data.resolved.members !== undefined) {
|
||||
const membermap = new Collection(Member);
|
||||
Object.entries(info.data.resolved.members).forEach(([id, member]) => {
|
||||
member.id = id;
|
||||
member.user = {id};
|
||||
if(this.channel.guild) {
|
||||
membermap.set(id, this.channel.guild.members.update(member, this.channel.guild));
|
||||
} else {
|
||||
const guild = this._client.guilds.get(info.guild_id);
|
||||
if(guild) {
|
||||
membermap.set(id, guild.members.update(member, guild));
|
||||
} else {
|
||||
membermap.set(id, new Member(member, guild, this._client));
|
||||
}
|
||||
}
|
||||
});
|
||||
this.data.resolved.members = membermap;
|
||||
}
|
||||
//Roles
|
||||
if(info.data.resolved.roles !== undefined) {
|
||||
const rolemap = new Collection(Role);
|
||||
Object.entries(info.data.resolved.roles).forEach(([id, role]) => {
|
||||
rolemap.set(id, new Role(role, this._client));
|
||||
});
|
||||
this.data.resolved.roles = rolemap;
|
||||
}
|
||||
//Channels
|
||||
if(info.data.resolved.channels !== undefined) {
|
||||
const channelmap = new Collection(Channel);
|
||||
Object.entries(info.data.resolved.channels).forEach(([id, channel]) => {
|
||||
channelmap.set(id, new Channel(channel, this._client));
|
||||
});
|
||||
this.data.resolved.channels = channelmap;
|
||||
}
|
||||
//Messages
|
||||
if(info.data.resolved.messages !== undefined) {
|
||||
const messagemap = new Collection(Message);
|
||||
Object.entries(info.data.resolved.messages).forEach(([id, message]) => {
|
||||
messagemap.set(id, new Message(message, this._client));
|
||||
});
|
||||
this.data.resolved.messages = messagemap;
|
||||
}
|
||||
}
|
||||
|
||||
if(info.guild_id !== undefined) {
|
||||
this.guildID = info.guild_id;
|
||||
}
|
||||
|
||||
if(info.member !== undefined) {
|
||||
if(this.channel.guild) {
|
||||
info.member.id = info.member.user.id;
|
||||
this.member = this.channel.guild.members.update(info.member, this.channel.guild);
|
||||
} else {
|
||||
const guild = this._client.guilds.get(info.guild_id);
|
||||
this.member = new Member(info.member, guild, this._client);
|
||||
}
|
||||
}
|
||||
|
||||
if(info.user !== undefined) {
|
||||
this.user = this._client.users.update(info.user, client);
|
||||
}
|
||||
|
||||
if(info.app_permissions !== undefined) {
|
||||
this.appPermissions = new Permission(info.app_permissions);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Acknowledges the interaction with a defer response
|
||||
* Note: You can **not** use more than 1 initial interaction response per interaction.
|
||||
* @arg {Number} [flags] 64 for Ephemeral
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async acknowledge(flags) {
|
||||
return this.defer(flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond to the interaction with a followup message
|
||||
* @arg {String | Object} content A string or object. If an object is passed:
|
||||
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
||||
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
|
||||
* @arg {Array<Object>} [content.components] An array of component objects
|
||||
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 0-4 and type 3 only)
|
||||
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3 only)
|
||||
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
||||
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
||||
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
||||
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
||||
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
||||
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
||||
* @arg {String} [content.components[].options[].description] The description for this option
|
||||
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
||||
* @arg {String} content.components[].options[].label The label for this option
|
||||
* @arg {Number | String} content.components[].options[].value The value for this option
|
||||
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3 only)
|
||||
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
|
||||
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
|
||||
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
||||
* @arg {String} [content.content] A content string
|
||||
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Array<Object>} [options.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Number} [content.flags] 64 for Ephemeral
|
||||
* @arg {Boolean} [content.tts] Set the message TTS flag
|
||||
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
||||
* @arg {Buffer} file.file A buffer containing file data
|
||||
* @arg {String} file.name What to name the file
|
||||
* @returns {Promise<Message?>}
|
||||
*/
|
||||
async createFollowup(content, file) {
|
||||
if(this.acknowledged === false) {
|
||||
throw new Error("createFollowup cannot be used to acknowledge an interaction, please use acknowledge, createMessage, or defer first.");
|
||||
}
|
||||
if(content !== undefined) {
|
||||
if(typeof content !== "object" || content === null) {
|
||||
content = {
|
||||
content: "" + content
|
||||
};
|
||||
} else if(content.content !== undefined && typeof content.content !== "string") {
|
||||
content.content = "" + content.content;
|
||||
}
|
||||
}
|
||||
if(file) {
|
||||
content.file = file;
|
||||
}
|
||||
return this._client.executeWebhook.call(this._client, this.applicationID, this.token, Object.assign({wait: true}, content));
|
||||
}
|
||||
|
||||
/**
|
||||
* Acknowledges the interaction with a message. If already acknowledged runs createFollowup
|
||||
* Note: You can **not** use more than 1 initial interaction response per interaction, use createFollowup if you have already responded with a different interaction response.
|
||||
* @arg {String | Object} content A string or object. If an object is passed:
|
||||
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
||||
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
|
||||
* @arg {Array<Object>} [content.components] An array of component objects
|
||||
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 0-4 and type 3 only)
|
||||
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3 only)
|
||||
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
||||
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
||||
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
||||
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
||||
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
||||
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
||||
* @arg {String} [content.components[].options[].description] The description for this option
|
||||
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
||||
* @arg {String} content.components[].options[].label The label for this option
|
||||
* @arg {Number | String} content.components[].options[].value The value for this option
|
||||
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3 only)
|
||||
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
|
||||
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
|
||||
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
||||
* @arg {String} [content.content] A content string
|
||||
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Boolean} [content.flags] 64 for Ephemeral
|
||||
* @arg {Boolean} [content.tts] Set the message TTS flag
|
||||
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
||||
* @arg {Buffer} file.file A buffer containing file data
|
||||
* @arg {String} file.name What to name the file
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async createMessage(content, file) {
|
||||
if(this.acknowledged === true) {
|
||||
return this.createFollowup(content, file);
|
||||
}
|
||||
if(content !== undefined) {
|
||||
if(typeof content !== "object" || content === null) {
|
||||
content = {
|
||||
content: "" + content
|
||||
};
|
||||
} else if(content.content !== undefined && typeof content.content !== "string") {
|
||||
content.content = "" + content.content;
|
||||
}
|
||||
if(content.content !== undefined || content.embeds || content.allowedMentions) {
|
||||
content.allowed_mentions = this._client._formatAllowedMentions(content.allowedMentions);
|
||||
}
|
||||
}
|
||||
return this._client.createInteractionResponse.call(this._client, this.id, this.token, {
|
||||
type: InteractionResponseTypes.CHANNEL_MESSAGE_WITH_SOURCE,
|
||||
data: content
|
||||
}, file).then(() => this.update());
|
||||
}
|
||||
|
||||
/**
|
||||
* Acknowledges the interaction with a defer response
|
||||
* Note: You can **not** use more than 1 initial interaction response per interaction.
|
||||
* @arg {Number} [flags] 64 for Ephemeral
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async defer(flags) {
|
||||
if(this.acknowledged === true) {
|
||||
throw new Error("You have already acknowledged this interaction.");
|
||||
}
|
||||
return this._client.createInteractionResponse.call(this._client, this.id, this.token, {
|
||||
type: InteractionResponseTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE,
|
||||
data: {
|
||||
flags: flags || 0
|
||||
}
|
||||
}).then(() => this.update());
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a message
|
||||
* @arg {String} messageID the id of the message to delete, or "@original" for the original response.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async deleteMessage(messageID) {
|
||||
if(this.acknowledged === false) {
|
||||
throw new Error("deleteMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, or defer first.");
|
||||
}
|
||||
return this._client.deleteWebhookMessage.call(this._client, this.applicationID, this.token, messageID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the Original message
|
||||
* Warning: Will error with ephemeral messages.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async deleteOriginalMessage() {
|
||||
if(this.acknowledged === false) {
|
||||
throw new Error("deleteOriginalMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, or defer first.");
|
||||
}
|
||||
return this._client.deleteWebhookMessage.call(this._client, this.applicationID, this.token, "@original");
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a message
|
||||
* @arg {String} messageID the id of the message to edit, or "@original" for the original response.
|
||||
* @arg {Object} content Interaction message edit options
|
||||
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
||||
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
|
||||
* @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
|
||||
* @arg {Array<Object>} [content.components] An array of component objects
|
||||
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 0-4 and type 3 only)
|
||||
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3 only)
|
||||
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
||||
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
||||
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
||||
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
||||
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
||||
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
||||
* @arg {String} [content.components[].options[].description] The description for this option
|
||||
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
||||
* @arg {String} content.components[].options[].label The label for this option
|
||||
* @arg {Number | String} content.components[].options[].value The value for this option
|
||||
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3 only)
|
||||
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
|
||||
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
|
||||
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
||||
* @arg {String} [content.content] A content string
|
||||
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
||||
* @arg {Buffer} file.file A buffer containing file data
|
||||
* @arg {String} file.name What to name the file
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
async editMessage(messageID, content, file) {
|
||||
if(this.acknowledged === false) {
|
||||
throw new Error("editMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, or defer first.");
|
||||
}
|
||||
if(content !== undefined) {
|
||||
if(typeof content !== "object" || content === null) {
|
||||
content = {
|
||||
content: "" + content
|
||||
};
|
||||
} else if(content.content !== undefined && typeof content.content !== "string") {
|
||||
content.content = "" + content.content;
|
||||
}
|
||||
}
|
||||
if(file) {
|
||||
content.file = file;
|
||||
}
|
||||
return this._client.editWebhookMessage.call(this._client, this.applicationID, this.token, messageID, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit the Original response message
|
||||
* @arg {Object} content Interaction message edit options
|
||||
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
||||
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
|
||||
* @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
|
||||
* @arg {Array<Object>} [content.components] An array of component objects
|
||||
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 0-4 and type 3 only)
|
||||
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3 only)
|
||||
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
||||
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
||||
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
||||
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
||||
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
||||
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
||||
* @arg {String} [content.components[].options[].description] The description for this option
|
||||
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
||||
* @arg {String} content.components[].options[].label The label for this option
|
||||
* @arg {Number | String} content.components[].options[].value The value for this option
|
||||
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3 only)
|
||||
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
|
||||
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
|
||||
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
||||
* @arg {String} [content.content] A content string
|
||||
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
||||
* @arg {Buffer} file.file A buffer containing file data
|
||||
* @arg {String} file.name What to name the file
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
async editOriginalMessage(content, file) {
|
||||
if(this.acknowledged === false) {
|
||||
throw new Error("editOriginalMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, or defer first.");
|
||||
}
|
||||
if(content !== undefined) {
|
||||
if(typeof content !== "object" || content === null) {
|
||||
content = {
|
||||
content: "" + content
|
||||
};
|
||||
} else if(content.content !== undefined && typeof content.content !== "string") {
|
||||
content.content = "" + content.content;
|
||||
}
|
||||
}
|
||||
if(file) {
|
||||
content.file = file;
|
||||
}
|
||||
return this._client.editWebhookMessage.call(this._client, this.applicationID, this.token, "@original", content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Original response message
|
||||
* Warning: Will error with ephemeral messages.
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
async getOriginalMessage() {
|
||||
if(this.acknowledged === false) {
|
||||
throw new Error("getOriginalMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, or defer first.");
|
||||
}
|
||||
return this._client.getWebhookMessage.call(this._client, this.applicationID, this.token, "@original");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = CommandInteraction;
|
412
node_modules/eris/lib/structures/ComponentInteraction.js
generated
vendored
Normal file
412
node_modules/eris/lib/structures/ComponentInteraction.js
generated
vendored
Normal file
@ -0,0 +1,412 @@
|
||||
"use strict";
|
||||
|
||||
const Interaction = require("./Interaction");
|
||||
const Message = require("./Message");
|
||||
const Member = require("./Member");
|
||||
const Permission = require("./Permission");
|
||||
const {InteractionResponseTypes} = require("../Constants");
|
||||
|
||||
/**
|
||||
* Represents a message component interaction. See Interaction for more properties.
|
||||
* @extends Interaction
|
||||
* @prop {Permission?} appPermissions The permissions the app or bot has within the channel the interaction was sent from
|
||||
* @prop {PrivateChannel | TextChannel | NewsChannel} channel The channel the interaction was created in. Can be partial with only the id if the channel is not cached.
|
||||
* @prop {Object} data The data attached to the interaction
|
||||
* @prop {Number} data.component_type The type of Message Component
|
||||
* @prop {String} data.custom_id The ID of the Message Component
|
||||
* @prop {Array<String>?} data.values The value of the run selected options (Select Menus Only)
|
||||
* @prop {String?} guildID The ID of the guild in which the interaction was created
|
||||
* @prop {Member?} member The member who triggered the interaction (This is only sent when the interaction is invoked within a guild)
|
||||
* @prop {Message?} message The message the interaction came from.
|
||||
* @prop {User?} user The user who triggered the interaction (This is only sent when the interaction is invoked within a dm)
|
||||
*/
|
||||
class ComponentInteraction extends Interaction {
|
||||
constructor(info, client) {
|
||||
super(info, client);
|
||||
|
||||
this.channel = this._client.getChannel(info.channel_id) || {
|
||||
id: info.channel_id
|
||||
};
|
||||
|
||||
this.data = info.data;
|
||||
|
||||
if(info.guild_id !== undefined) {
|
||||
this.guildID = info.guild_id;
|
||||
}
|
||||
|
||||
if(info.member !== undefined) {
|
||||
if(this.channel.guild) {
|
||||
info.member.id = info.member.user.id;
|
||||
this.member = this.channel.guild.members.update(info.member, this.channel.guild);
|
||||
} else {
|
||||
const guild = this._client.guilds.get(info.guild_id);
|
||||
this.member = new Member(info.member, guild, this._client);
|
||||
}
|
||||
}
|
||||
|
||||
if(info.message !== undefined) {
|
||||
this.message = new Message(info.message, this._client);
|
||||
}
|
||||
|
||||
if(info.user !== undefined) {
|
||||
this.user = this._client.users.update(info.user, client);
|
||||
}
|
||||
|
||||
if(info.app_permissions !== undefined) {
|
||||
this.appPermissions = new Permission(info.app_permissions);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Acknowledges the interaction with a defer message update response
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async acknowledge() {
|
||||
return this.deferUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond to the interaction with a followup message
|
||||
* @arg {String | Object} content A string or object. If an object is passed:
|
||||
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
||||
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
|
||||
* @arg {Array<Object>} [content.components] An array of component objects
|
||||
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 0-4 and type 3 only)
|
||||
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3 only)
|
||||
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
||||
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
||||
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
||||
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
||||
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
||||
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
||||
* @arg {String} [content.components[].options[].description] The description for this option
|
||||
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
||||
* @arg {String} content.components[].options[].label The label for this option
|
||||
* @arg {Number | String} content.components[].options[].value The value for this option
|
||||
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3 only)
|
||||
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
|
||||
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
|
||||
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
||||
* @arg {String} [content.content] A content string
|
||||
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Array<Object>} [options.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Number} [content.flags] 64 for Ephemeral
|
||||
* @arg {Boolean} [content.tts] Set the message TTS flag
|
||||
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
||||
* @arg {Buffer} file.file A buffer containing file data
|
||||
* @arg {String} file.name What to name the file
|
||||
* @returns {Promise<Message?>}
|
||||
*/
|
||||
async createFollowup(content, file) {
|
||||
if(this.acknowledged === false) {
|
||||
throw new Error("createFollowup cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, or editParent first.");
|
||||
}
|
||||
if(content !== undefined) {
|
||||
if(typeof content !== "object" || content === null) {
|
||||
content = {
|
||||
content: "" + content
|
||||
};
|
||||
} else if(content.content !== undefined && typeof content.content !== "string") {
|
||||
content.content = "" + content.content;
|
||||
}
|
||||
}
|
||||
if(file) {
|
||||
content.file = file;
|
||||
}
|
||||
return this._client.executeWebhook.call(this._client, this.applicationID, this.token, Object.assign({wait: true}, content));
|
||||
}
|
||||
|
||||
/**
|
||||
* Acknowledges the interaction with a message. If already acknowledged runs createFollowup
|
||||
* Note: You can **not** use more than 1 initial interaction response per interaction, use createFollowup if you have already responded with a different interaction response.
|
||||
* @arg {String | Object} content A string or object. If an object is passed:
|
||||
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
||||
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
|
||||
* @arg {Array<Object>} [content.components] An array of component objects
|
||||
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 0-4 and type 3 only)
|
||||
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3 only)
|
||||
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
||||
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
||||
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
||||
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
||||
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
||||
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
||||
* @arg {String} [content.components[].options[].description] The description for this option
|
||||
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
||||
* @arg {String} content.components[].options[].label The label for this option
|
||||
* @arg {Number | String} content.components[].options[].value The value for this option
|
||||
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3 only)
|
||||
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
|
||||
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
|
||||
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
||||
* @arg {String} [content.content] A content string
|
||||
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Boolean} [content.flags] 64 for Ephemeral
|
||||
* @arg {Boolean} [content.tts] Set the message TTS flag
|
||||
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
||||
* @arg {Buffer} file.file A buffer containing file data
|
||||
* @arg {String} file.name What to name the file
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async createMessage(content, file) {
|
||||
if(this.acknowledged === true) {
|
||||
return this.createFollowup(content, file);
|
||||
}
|
||||
if(content !== undefined) {
|
||||
if(typeof content !== "object" || content === null) {
|
||||
content = {
|
||||
content: "" + content
|
||||
};
|
||||
} else if(content.content !== undefined && typeof content.content !== "string") {
|
||||
content.content = "" + content.content;
|
||||
}
|
||||
if(content.content !== undefined || content.embeds || content.allowedMentions) {
|
||||
content.allowed_mentions = this._client._formatAllowedMentions(content.allowedMentions);
|
||||
}
|
||||
}
|
||||
return this._client.createInteractionResponse.call(this._client, this.id, this.token, {
|
||||
type: InteractionResponseTypes.CHANNEL_MESSAGE_WITH_SOURCE,
|
||||
data: content
|
||||
}, file).then(() => this.update());
|
||||
}
|
||||
|
||||
/**
|
||||
* Acknowledges the interaction with a defer response
|
||||
* Note: You can **not** use more than 1 initial interaction response per interaction.
|
||||
* @arg {Number} [flags] 64 for Ephemeral
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async defer(flags) {
|
||||
if(this.acknowledged === true) {
|
||||
throw new Error("You have already acknowledged this interaction.");
|
||||
}
|
||||
return this._client.createInteractionResponse.call(this._client, this.id, this.token, {
|
||||
type: InteractionResponseTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE,
|
||||
data: {
|
||||
flags: flags || 0
|
||||
}
|
||||
}).then(() => this.update());
|
||||
}
|
||||
|
||||
/**
|
||||
* Acknowledges the interaction with a defer message update response
|
||||
* Note: You can **not** use more than 1 initial interaction response per interaction.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async deferUpdate() {
|
||||
if(this.acknowledged === true) {
|
||||
throw new Error("You have already acknowledged this interaction.");
|
||||
}
|
||||
return this._client.createInteractionResponse.call(this._client, this.id, this.token, {
|
||||
type: InteractionResponseTypes.DEFERRED_UPDATE_MESSAGE
|
||||
}).then(() => this.update());
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a message
|
||||
* @arg {String} messageID the id of the message to delete, or "@original" for the original response.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async deleteMessage(messageID) {
|
||||
if(this.acknowledged === false) {
|
||||
throw new Error("deleteMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, or editParent first.");
|
||||
}
|
||||
return this._client.deleteWebhookMessage.call(this._client, this.applicationID, this.token, messageID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the parent message
|
||||
* Warning: Will error with ephemeral messages.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async deleteOriginalMessage() {
|
||||
if(this.acknowledged === false) {
|
||||
throw new Error("deleteOriginalMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, or editParent first.");
|
||||
}
|
||||
return this._client.deleteWebhookMessage.call(this._client, this.applicationID, this.token, "@original");
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a message
|
||||
* @arg {String} messageID the id of the message to edit, or "@original" for the original response.
|
||||
* @arg {Object} content Interaction message edit options
|
||||
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
||||
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
|
||||
* @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
|
||||
* @arg {Array<Object>} [content.components] An array of component objects
|
||||
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 0-4 and type 3 only)
|
||||
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3 only)
|
||||
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
||||
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
||||
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
||||
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
||||
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
||||
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
||||
* @arg {String} [content.components[].options[].description] The description for this option
|
||||
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
||||
* @arg {String} content.components[].options[].label The label for this option
|
||||
* @arg {Number | String} content.components[].options[].value The value for this option
|
||||
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3 only)
|
||||
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
|
||||
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
|
||||
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
||||
* @arg {String} [content.content] A content string
|
||||
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
||||
* @arg {Buffer} file.file A buffer containing file data
|
||||
* @arg {String} file.name What to name the file
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
async editMessage(messageID, content, file) {
|
||||
if(this.acknowledged === false) {
|
||||
throw new Error("editMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, or editParent first.");
|
||||
}
|
||||
if(content !== undefined) {
|
||||
if(typeof content !== "object" || content === null) {
|
||||
content = {
|
||||
content: "" + content
|
||||
};
|
||||
} else if(content.content !== undefined && typeof content.content !== "string") {
|
||||
content.content = "" + content.content;
|
||||
}
|
||||
}
|
||||
if(file) {
|
||||
content.file = file;
|
||||
}
|
||||
return this._client.editWebhookMessage.call(this._client, this.applicationID, this.token, messageID, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit the parent message
|
||||
* @arg {Object} content Interaction message edit options
|
||||
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
||||
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
|
||||
* @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
|
||||
* @arg {Array<Object>} [content.components] An array of component objects
|
||||
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 0-4 and type 3 only)
|
||||
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3 only)
|
||||
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
||||
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
||||
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
||||
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
||||
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
||||
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
||||
* @arg {String} [content.components[].options[].description] The description for this option
|
||||
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
||||
* @arg {String} content.components[].options[].label The label for this option
|
||||
* @arg {Number | String} content.components[].options[].value The value for this option
|
||||
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3 only)
|
||||
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
|
||||
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
|
||||
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
||||
* @arg {String} [content.content] A content string
|
||||
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
||||
* @arg {Buffer} file.file A buffer containing file data
|
||||
* @arg {String} file.name What to name the file
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
async editOriginalMessage(content, file) {
|
||||
if(this.acknowledged === false) {
|
||||
throw new Error("editOriginalMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, or editParent first.");
|
||||
}
|
||||
if(content !== undefined) {
|
||||
if(typeof content !== "object" || content === null) {
|
||||
content = {
|
||||
content: "" + content
|
||||
};
|
||||
} else if(content.content !== undefined && typeof content.content !== "string") {
|
||||
content.content = "" + content.content;
|
||||
}
|
||||
}
|
||||
if(file) {
|
||||
content.file = file;
|
||||
}
|
||||
return this._client.editWebhookMessage.call(this._client, this.applicationID, this.token, "@original", content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Acknowledges the interaction by editing the parent message. If already acknowledged runs editOriginalMessage
|
||||
* Note: You can **not** use more than 1 initial interaction response per interaction, use edit if you have already responded with a different interaction response.
|
||||
* Warning: Will error with ephemeral messages.
|
||||
* @arg {String | Object} content What to edit the message with
|
||||
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
||||
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
|
||||
* @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
|
||||
* @arg {Array<Object>} [content.components] An array of component objects
|
||||
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 0-4 and type 3 only)
|
||||
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3 only)
|
||||
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
||||
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
||||
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
||||
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
||||
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
||||
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
||||
* @arg {String} [content.components[].options[].description] The description for this option
|
||||
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
||||
* @arg {String} content.components[].options[].label The label for this option
|
||||
* @arg {Number | String} content.components[].options[].value The value for this option
|
||||
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3 only)
|
||||
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
|
||||
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
|
||||
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
||||
* @arg {String} [content.content] A content string
|
||||
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Boolean} [content.flags] 64 for Ephemeral
|
||||
* @arg {Boolean} [content.tts] Set the message TTS flag
|
||||
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
||||
* @arg {Buffer} file.file A buffer containing file data
|
||||
* @arg {String} file.name What to name the file
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async editParent(content, file) {
|
||||
if(this.acknowledged === true) {
|
||||
return this.editOriginalMessage(content);
|
||||
}
|
||||
if(content !== undefined) {
|
||||
if(typeof content !== "object" || content === null) {
|
||||
content = {
|
||||
content: "" + content
|
||||
};
|
||||
} else if(content.content !== undefined && typeof content.content !== "string") {
|
||||
content.content = "" + content.content;
|
||||
}
|
||||
if(content.content !== undefined || content.embeds || content.allowedMentions) {
|
||||
content.allowed_mentions = this._client._formatAllowedMentions(content.allowedMentions);
|
||||
}
|
||||
}
|
||||
return this._client.createInteractionResponse.call(this._client, this.id, this.token, {
|
||||
type: InteractionResponseTypes.UPDATE_MESSAGE,
|
||||
data: content
|
||||
}, file).then(() => this.update());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parent message
|
||||
* Warning: Will error with ephemeral messages.
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
async getOriginalMessage() {
|
||||
if(this.acknowledged === false) {
|
||||
throw new Error("getOriginalMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, or editParent first.");
|
||||
}
|
||||
return this._client.getWebhookMessage.call(this._client, this.applicationID, this.token, "@original");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = ComponentInteraction;
|
46
node_modules/eris/lib/structures/ExtendedUser.js
generated
vendored
Normal file
46
node_modules/eris/lib/structures/ExtendedUser.js
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
|
||||
const User = require("./User");
|
||||
|
||||
/**
|
||||
* Represents an extended user
|
||||
* @extends User
|
||||
* @prop {String} email The email of the user
|
||||
* @prop {Boolean} mfaEnabled Whether the user has enabled two-factor authentication
|
||||
* @prop {Number} premiumType The type of Nitro subscription on the user's account
|
||||
* @prop {Boolean} verified Whether the account email has been verified
|
||||
*/
|
||||
class ExtendedUser extends User {
|
||||
constructor(data, client) {
|
||||
super(data, client);
|
||||
this.update(data);
|
||||
}
|
||||
|
||||
update(data) {
|
||||
super.update(data);
|
||||
if(data.email !== undefined) {
|
||||
this.email = data.email;
|
||||
}
|
||||
if(data.verified !== undefined) {
|
||||
this.verified = data.verified;
|
||||
}
|
||||
if(data.mfa_enabled !== undefined) {
|
||||
this.mfaEnabled = data.mfa_enabled;
|
||||
}
|
||||
if(data.premium_type !== undefined) {
|
||||
this.premiumType = data.premium_type;
|
||||
}
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"email",
|
||||
"mfaEnabled",
|
||||
"premium",
|
||||
"verified",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ExtendedUser;
|
97
node_modules/eris/lib/structures/GroupChannel.js
generated
vendored
Normal file
97
node_modules/eris/lib/structures/GroupChannel.js
generated
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
"use strict";
|
||||
|
||||
const Collection = require("../util/Collection");
|
||||
const Endpoints = require("../rest/Endpoints");
|
||||
const PrivateChannel = require("./PrivateChannel");
|
||||
const User = require("./User");
|
||||
|
||||
/**
|
||||
* [USER ACCOUNT] Represents a group channel. See PrivateChannel docs for additional properties.
|
||||
* @extends PrivateChannel
|
||||
* @prop {Call?} call The current group call, if any
|
||||
* @prop {String?} icon The hash of the group channel icon
|
||||
* @prop {String?} iconURL The URL of the group channel icon
|
||||
* @prop {Call?} lastCall The previous group call, if any
|
||||
* @prop {String} mention A string that mentions the channel
|
||||
* @prop {String} name The name of the group channel
|
||||
* @prop {String} ownerID The ID of the user that is the group owner
|
||||
* @prop {Collection<User>} recipients The recipients in this private channel
|
||||
*/
|
||||
class GroupChannel extends PrivateChannel { // (╯°□°)╯︵ ┻━┻
|
||||
constructor(data, client) {
|
||||
super(data, client);
|
||||
this.recipients = new Collection(User);
|
||||
data.recipients.forEach((recipient) => {
|
||||
this.recipients.add(client.options.restMode ? new User(recipient, client) : client.users.add(recipient, client));
|
||||
});
|
||||
this.update(data);
|
||||
}
|
||||
|
||||
update(data) {
|
||||
if(data.name !== undefined) {
|
||||
this.name = data.name;
|
||||
}
|
||||
if(data.owner_id !== undefined) {
|
||||
this.ownerID = data.owner_id;
|
||||
}
|
||||
if(data.icon !== undefined) {
|
||||
this.icon = data.icon;
|
||||
}
|
||||
}
|
||||
|
||||
get iconURL() {
|
||||
return this.icon ? this.client._formatImage(Endpoints.CHANNEL_ICON(this.id, this.icon)) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* [USER ACCOUNT] Add a user to the group
|
||||
* @arg {String} userID The ID of the target user
|
||||
* @returns {Promise}
|
||||
*/
|
||||
addRecipient(userID) {
|
||||
return this.client.addGroupRecipient.call(this.client, this.id, userID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the group's icon with the given format and size
|
||||
* @arg {String} [format] The filetype of the icon ("jpg", "jpeg", "png", "gif", or "webp")
|
||||
* @arg {Number} [size] The size of the icon (any power of two between 16 and 4096)
|
||||
* @returns {String?}
|
||||
*/
|
||||
dynamicIconURL(format, size) {
|
||||
return this.icon ? this.client._formatImage(Endpoints.CHANNEL_ICON(this.id, this.icon), format, size) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* [USER ACCOUNT] Edit the channel's properties
|
||||
* @arg {Object} options The properties to edit
|
||||
* @arg {String} [options.name] The name of the channel
|
||||
* @arg {String} [options.icon] The icon of the channel as a base64 data URI (group channels only). Note: base64 strings alone are not base64 data URI strings
|
||||
* @arg {String} [options.ownerID] The ID of the channel owner (group channels only)
|
||||
* @returns {Promise<GroupChannel>}
|
||||
*/
|
||||
edit(options) {
|
||||
return this.client.editChannel.call(this.client, this.id, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* [USER ACCOUNT] Remove a user from the group
|
||||
* @arg {String} userID The ID of the target user
|
||||
* @returns {Promise}
|
||||
*/
|
||||
removeRecipient(userID) {
|
||||
return this.client.removeGroupRecipient.call(this.client, this.id, userID);
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"icon",
|
||||
"name",
|
||||
"ownerID",
|
||||
"recipients",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = GroupChannel;
|
1366
node_modules/eris/lib/structures/Guild.js
generated
vendored
Normal file
1366
node_modules/eris/lib/structures/Guild.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
157
node_modules/eris/lib/structures/GuildAuditLogEntry.js
generated
vendored
Normal file
157
node_modules/eris/lib/structures/GuildAuditLogEntry.js
generated
vendored
Normal file
@ -0,0 +1,157 @@
|
||||
"use strict";
|
||||
|
||||
const Base = require("./Base");
|
||||
const Invite = require("./Invite");
|
||||
const {AuditLogActions} = require("../Constants");
|
||||
|
||||
/**
|
||||
* Represents a guild audit log entry describing a moderation action
|
||||
* @prop {Number} actionType The action type of the entry. See Constants.AuditLogActions for more details
|
||||
* @prop {Object?} after The properties of the targeted object after the action was taken
|
||||
* For example, if a channel was renamed from #general to #potato, this would be `{name: "potato"}``
|
||||
* @prop {Object?} before The properties of the targeted object before the action was taken
|
||||
* For example, if a channel was renamed from #general to #potato, this would be `{name: "general"}``
|
||||
* @prop {(CategoryChannel | TextChannel | TextVoiceChannel | NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel | StageChannel)?} 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
|
||||
* @prop {Number?} count The number of entities targeted
|
||||
* For example, for action type 26 (MEMBER_MOVE), this is the number of members that were moved/disconnected from the voice channel
|
||||
* @prop {Number?} deleteMemberDays The number of days of inactivity to prune for, action type 21 (MEMBER_PRUNE) only
|
||||
* @prop {Guild} guild The guild containing the entry
|
||||
* @prop {String} id The ID of the entry
|
||||
* @prop {(Member | Object)?} member The member described by the permission overwrite, action types 13-15 (CHANNEL\_OVERWRITE\_CREATE/UPDATE/DELETE) only. If the member is not cached, this could be {id: String}
|
||||
* @prop {Number?} membersRemoved The number of members pruned from the server, action type 21 (MEMBER_PRUNE) only
|
||||
* @prop {(Message | Object)?} message The message that was (un)pinned, action types 74/75 (MESSAGE_PIN/UNPIN) only. If the message is not cached, this will be an object with an `id` key. No other property is guaranteed.
|
||||
* @prop {String?} reason The reason for the action
|
||||
* @prop {(Role | Object)?} role The role described by the permission overwrite, action types 13-15 (CHANNEL\_OVERWRITE\_CREATE/UPDATE/DELETE) only. If the role is not cached, this could be {id: String, name: String}
|
||||
* @prop {(CategoryChannel | Guild | Member | Invite | Role | Object | TextChannel | TextVoiceChannel | NewsChannel)?} target The object of the action target
|
||||
* If the item is not cached, this property will be null
|
||||
* If the action targets a guild, this could be a Guild object
|
||||
* If the action targets a guild channel, this could be a CategoryChannel, TextChannel, or TextVoiceChannel object
|
||||
* If the action targets a member, this could be a Member object
|
||||
* If the action targets a role, this could be a Role object
|
||||
* If the action targets an invite, this is an Invite object
|
||||
* If the action targets a webhook, this is null
|
||||
* If the action targets a emoji, this could be an emoji object
|
||||
* If the action targets a sticker, this could be a sticker object
|
||||
* If the action targets a message, this is a User object
|
||||
* @prop {String} targetID The ID of the action target
|
||||
* @prop {User} user The user that performed the action
|
||||
*/
|
||||
class GuildAuditLogEntry extends Base {
|
||||
constructor(data, guild) {
|
||||
super(data.id);
|
||||
this.guild = guild;
|
||||
|
||||
this.actionType = data.action_type;
|
||||
this.reason = data.reason || null;
|
||||
this.user = guild.shard.client.users.get(data.user_id);
|
||||
this.before = null;
|
||||
this.after = null;
|
||||
if(data.changes) {
|
||||
this.before = {};
|
||||
this.after = {};
|
||||
data.changes.forEach((change) => {
|
||||
if(change.old_value != undefined) {
|
||||
this.before[change.key] = change.old_value;
|
||||
}
|
||||
if(change.new_value != undefined) {
|
||||
this.after[change.key] = change.new_value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if(data.target_id) {
|
||||
this.targetID = data.target_id;
|
||||
}
|
||||
if(data.options) {
|
||||
if(data.options.count) {
|
||||
this.count = +data.options.count;
|
||||
}
|
||||
if(data.options.channel_id) {
|
||||
if(this.actionType >= 83) {
|
||||
this.channel = guild.threads.get(data.options.channel_id);
|
||||
} else {
|
||||
this.channel = guild.channels.get(data.options.channel_id);
|
||||
}
|
||||
if(data.options.message_id) {
|
||||
this.message = this.channel && this.channel.messages.get(data.options.message_id) || {id: data.options.message_id};
|
||||
}
|
||||
}
|
||||
if(data.options.delete_member_days) {
|
||||
this.deleteMemberDays = +data.options.delete_member_days;
|
||||
this.membersRemoved = +data.options.members_removed;
|
||||
}
|
||||
if(data.options.type) {
|
||||
if(data.options.type === "1") {
|
||||
this.member = guild.members.get(data.options.id) || {
|
||||
id: data.options.id
|
||||
};
|
||||
} else if(data.options.type === "0") {
|
||||
this.role = guild.roles.get(data.options.id) || {
|
||||
id: data.options.id,
|
||||
name: data.options.role_name
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get target() { // pay more, get less
|
||||
if(this.actionType < 10) { // Guild
|
||||
return this.guild;
|
||||
} else if(this.actionType < 20) { // Channel
|
||||
return this.guild && this.guild.channels.get(this.targetID);
|
||||
} else if(this.actionType < 30) { // Member
|
||||
if(this.actionType === AuditLogActions.MEMBER_MOVE || this.actionType === AuditLogActions.MEMBER_DISCONNECT) { // MEMBER_MOVE / MEMBER_DISCONNECT
|
||||
return null;
|
||||
}
|
||||
return this.guild && this.guild.members.get(this.targetID);
|
||||
} else if(this.actionType < 40) { // Role
|
||||
return this.guild && this.guild.roles.get(this.targetID);
|
||||
} else if(this.actionType < 50) { // Invite
|
||||
const changes = this.actionType === 42 ? this.before : this.after; // Apparently the meaning of life is a deleted invite
|
||||
return new Invite({
|
||||
code: changes.code,
|
||||
channel: changes.channel,
|
||||
guild: this.guild,
|
||||
uses: changes.uses,
|
||||
max_uses: changes.max_uses,
|
||||
max_age: changes.max_age,
|
||||
temporary: changes.temporary
|
||||
}, this.guild && this.guild.shard.client);
|
||||
} else if(this.actionType < 60) { // Webhook
|
||||
return null; // Go get the webhook yourself
|
||||
} else if(this.actionType < 70) { // Emoji
|
||||
return this.guild && this.guild.emojis.find((emoji) => emoji.id === this.targetID);
|
||||
} else if(this.actionType < 80) { // Message
|
||||
return this.guild && this.guild.shard.client.users.get(this.targetID);
|
||||
} else if(this.actionType < 83) { // Integrations
|
||||
return null;
|
||||
} else if(this.actionType < 90) { // Stage Instances
|
||||
return this.guild && this.guild.threads.get(this.targetID);
|
||||
} else if(this.actionType < 100) { // Sticker
|
||||
return this.guild && this.guild.stickers.find((sticker) => sticker.id === this.targetID);
|
||||
} else {
|
||||
throw new Error("Unrecognized action type: " + this.actionType);
|
||||
}
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"actionType",
|
||||
"after",
|
||||
"before",
|
||||
"channel",
|
||||
"count",
|
||||
"deleteMemberDays",
|
||||
"member",
|
||||
"membersRemoved",
|
||||
"reason",
|
||||
"role",
|
||||
"targetID",
|
||||
"user",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = GuildAuditLogEntry;
|
168
node_modules/eris/lib/structures/GuildChannel.js
generated
vendored
Normal file
168
node_modules/eris/lib/structures/GuildChannel.js
generated
vendored
Normal file
@ -0,0 +1,168 @@
|
||||
"use strict";
|
||||
|
||||
const Channel = require("./Channel");
|
||||
const Collection = require("../util/Collection");
|
||||
const Permission = require("./Permission");
|
||||
const {Permissions} = require("../Constants");
|
||||
const PermissionOverwrite = require("./PermissionOverwrite");
|
||||
|
||||
/**
|
||||
* Represents a guild channel. You also probably want to look at CategoryChannel, NewsChannel, StoreChannel, TextChannel, and TextVoiceChannel. See Channel for extra properties.
|
||||
* @extends Channel
|
||||
* @prop {Guild} guild The guild that owns the channel
|
||||
* @prop {String} id The ID of the channel
|
||||
* @prop {String} name The name of the channel
|
||||
* @prop {Boolean} nsfw Whether the channel is an NSFW channel or not
|
||||
* @prop {String?} parentID The ID of the category this channel belongs to or the channel ID where the thread originated from (thread channels only)
|
||||
* @prop {Collection<PermissionOverwrite>} permissionOverwrites Collection of PermissionOverwrites in this channel
|
||||
* @prop {Number} position The position of the channel
|
||||
*/
|
||||
class GuildChannel extends Channel {
|
||||
constructor(data, client) {
|
||||
super(data, client);
|
||||
this.guild = client.guilds.get(data.guild_id) || {
|
||||
id: data.guild_id
|
||||
};
|
||||
|
||||
this.update(data);
|
||||
}
|
||||
|
||||
update(data) {
|
||||
if(data.type !== undefined) {
|
||||
this.type = data.type;
|
||||
}
|
||||
if(data.name !== undefined) {
|
||||
this.name = data.name;
|
||||
}
|
||||
if(data.position !== undefined) {
|
||||
this.position = data.position;
|
||||
}
|
||||
if(data.parent_id !== undefined) {
|
||||
this.parentID = data.parent_id;
|
||||
}
|
||||
this.nsfw = data.nsfw;
|
||||
if(data.permission_overwrites) {
|
||||
this.permissionOverwrites = new Collection(PermissionOverwrite);
|
||||
data.permission_overwrites.forEach((overwrite) => {
|
||||
this.permissionOverwrites.add(overwrite);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the channel
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise}
|
||||
*/
|
||||
delete(reason) {
|
||||
return this.client.deleteChannel.call(this.client, this.id, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a channel permission overwrite
|
||||
* @arg {String} overwriteID The ID of the overwritten user or role
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise}
|
||||
*/
|
||||
deletePermission(overwriteID, reason) {
|
||||
return this.client.deleteChannelPermission.call(this.client, this.id, overwriteID, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit the channel's properties
|
||||
* @arg {Object} options The properties to edit
|
||||
* @arg {Boolean} [options.archived] The archive status of the channel (thread channels only)
|
||||
* @arg {Number} [options.autoArchiveDuration] The duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080 (thread channels only)
|
||||
* @arg {Number} [options.bitrate] The bitrate of the channel (guild voice channels only)
|
||||
* @arg {Number?} [options.defaultAutoArchiveDuration] The default duration of newly created threads in minutes to automatically archive the thread after inactivity (60, 1440, 4320, 10080) (guild text/news channels only)
|
||||
* @arg {Boolean} [options.invitable] Whether non-moderators can add other non-moderators to the channel (private thread channels only)
|
||||
* @arg {Boolean} [options.locked] The lock status of the channel (thread channels only)
|
||||
* @arg {String} [options.name] The name of the channel
|
||||
* @arg {Boolean} [options.nsfw] The nsfw status of the channel
|
||||
* @arg {Number?} [options.parentID] The ID of the parent channel category for this channel (guild text/voice channels only) or the channel ID where the thread originated from (thread channels only)
|
||||
* @arg {Array<Object>} [options.permissionOverwrites] An array containing permission overwrite objects
|
||||
* @arg {Number} [options.position] The sorting position of the channel
|
||||
* @arg {Number} [options.rateLimitPerUser] The time in seconds a user has to wait before sending another message (does not affect bots or users with manageMessages/manageChannel permissions) (guild text and thread channels only)
|
||||
* @arg {String?} [options.rtcRegion] The RTC region ID of the channel (automatic if `null`) (guild voice channels only)
|
||||
* @arg {String} [options.topic] The topic of the channel (guild text channels only)
|
||||
* @arg {Number} [options.userLimit] The channel user limit (guild voice channels only)
|
||||
* @arg {Number} [options.videoQualityMode] The camera video quality mode of the channel (guild voice channels only). `1` is auto, `2` is 720p
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise<CategoryChannel | GroupChannel | TextChannel | TextVoiceChannel | NewsChannel | NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel>}
|
||||
*/
|
||||
edit(options, reason) {
|
||||
return this.client.editChannel.call(this.client, this.id, options, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a channel permission overwrite
|
||||
* @arg {String} overwriteID The ID of the overwritten user or role
|
||||
* @arg {BigInt | Number} allow The permissions number for allowed permissions
|
||||
* @arg {BigInt | Number} deny The permissions number for denied permissions
|
||||
* @arg {Number} type The object type of the overwrite, either 1 for "member" or 0 for "role"
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise<PermissionOverwrite>}
|
||||
*/
|
||||
editPermission(overwriteID, allow, deny, type, reason) {
|
||||
return this.client.editChannelPermission.call(this.client, this.id, overwriteID, allow, deny, type, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit the channel's position. Note that channel position numbers are lowest on top and highest at the bottom.
|
||||
* @arg {Number} position The new position of the channel
|
||||
* @arg {Object} [options] Additional options when editing position
|
||||
* @arg {Boolean} [options.lockPermissions] Whether to sync the permissions with the new parent if moving to a new category
|
||||
* @arg {String} [options.parentID] The new parent ID (category channel) for the channel that is moved
|
||||
* @returns {Promise}
|
||||
*/
|
||||
editPosition(position, options) {
|
||||
return this.client.editChannelPosition.call(this.client, this.id, position, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channel-specific permissions of a member
|
||||
* @arg {String | Member | Object} memberID The ID of the member or a Member object
|
||||
* @returns {Permission}
|
||||
*/
|
||||
permissionsOf(memberID) {
|
||||
const member = typeof memberID === "string" ? this.guild.members.get(memberID) : memberID;
|
||||
let permission = this.guild.permissionsOf(member).allow;
|
||||
if(permission & Permissions.administrator) {
|
||||
return new Permission(Permissions.all);
|
||||
}
|
||||
const channel = this instanceof ThreadChannel ? this.guild.channels.get(this.parentID) : this;
|
||||
let overwrite = channel && channel.permissionOverwrites.get(this.guild.id);
|
||||
if(overwrite) {
|
||||
permission = (permission & ~overwrite.deny) | overwrite.allow;
|
||||
}
|
||||
let deny = 0n;
|
||||
let allow = 0n;
|
||||
for(const roleID of member.roles) {
|
||||
if((overwrite = channel && channel.permissionOverwrites.get(roleID))) {
|
||||
deny |= overwrite.deny;
|
||||
allow |= overwrite.allow;
|
||||
}
|
||||
}
|
||||
permission = (permission & ~deny) | allow;
|
||||
overwrite = channel && channel.permissionOverwrites.get(member.id);
|
||||
if(overwrite) {
|
||||
permission = (permission & ~overwrite.deny) | overwrite.allow;
|
||||
}
|
||||
return new Permission(permission);
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"name",
|
||||
"nsfw",
|
||||
"parentID",
|
||||
"permissionOverwrites",
|
||||
"position",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = GuildChannel;
|
||||
|
||||
const ThreadChannel = require("./ThreadChannel");
|
119
node_modules/eris/lib/structures/GuildIntegration.js
generated
vendored
Normal file
119
node_modules/eris/lib/structures/GuildIntegration.js
generated
vendored
Normal file
@ -0,0 +1,119 @@
|
||||
"use strict";
|
||||
|
||||
const Base = require("./Base");
|
||||
|
||||
/**
|
||||
* Represents a guild integration
|
||||
* @prop {Object} account Info on the integration account
|
||||
* @prop {String} account.id The ID of the integration account
|
||||
* @prop {String} account.name The name of the integration account
|
||||
* @prop {Object?} application The bot/OAuth2 application for Discord integrations. See [the Discord docs](https://discord.com/developers/docs/resources/guild#integration-application-object)
|
||||
* @prop {Number} createdAt Timestamp of the guild integration's creation
|
||||
* @prop {Boolean} enabled Whether the integration is enabled or not
|
||||
* @prop {Boolean?} enableEmoticons Whether integration emoticons are enabled or not
|
||||
* @prop {Number?} expireBehavior behavior of expired subscriptions
|
||||
* @prop {Number?} expireGracePeriod grace period for expired subscriptions
|
||||
* @prop {String} id The ID of the integration
|
||||
* @prop {String} name The name of the integration
|
||||
* @prop {Boolean?} revoked Whether or not the application was revoked
|
||||
* @prop {String?} roleID The ID of the role connected to the integration
|
||||
* @prop {Number?} subscriberCount number of subscribers
|
||||
* @prop {Number?} syncedAt Unix timestamp of last integration sync
|
||||
* @prop {Boolean?} syncing Whether the integration is syncing or not
|
||||
* @prop {String} type The type of the integration
|
||||
* @prop {User?} user The user connected to the integration
|
||||
*/
|
||||
class GuildIntegration extends Base {
|
||||
constructor(data, guild) {
|
||||
super(data.id);
|
||||
this.guild = guild;
|
||||
this.name = data.name;
|
||||
this.type = data.type;
|
||||
if(data.role_id !== undefined) {
|
||||
this.roleID = data.role_id;
|
||||
}
|
||||
if(data.user) {
|
||||
this.user = guild.shard.client.users.add(data.user, guild.shard.client);
|
||||
}
|
||||
this.account = data.account; // not worth making a class for
|
||||
this.update(data);
|
||||
}
|
||||
|
||||
update(data) {
|
||||
this.enabled = data.enabled;
|
||||
if(data.syncing !== undefined) {
|
||||
this.syncing = data.syncing;
|
||||
}
|
||||
if(data.expire_behavior !== undefined) {
|
||||
this.expireBehavior = data.expire_behavior;
|
||||
}
|
||||
if(data.expire_behavior !== undefined) {
|
||||
this.expireGracePeriod = data.expire_grace_period;
|
||||
}
|
||||
if(data.enable_emoticons) {
|
||||
this.enableEmoticons = data.enable_emoticons;
|
||||
}
|
||||
if(data.subscriber_count !== undefined) {
|
||||
this.subscriberCount = data.subscriber_count;
|
||||
}
|
||||
if(data.synced_at !== undefined) {
|
||||
this.syncedAt = data.synced_at;
|
||||
}
|
||||
if(data.revoked !== undefined) {
|
||||
this.revoked = data.revoked;
|
||||
}
|
||||
if(data.application !== undefined) {
|
||||
this.application = data.application;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the guild integration
|
||||
* @returns {Promise}
|
||||
*/
|
||||
delete() {
|
||||
return this.guild.shard.client.deleteGuildIntegration.call(this.guild.shard.client, this.guild.id, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit the guild integration
|
||||
* @arg {Object} options The properties to edit
|
||||
* @arg {String} [options.expireBehavior] What to do when a user's subscription runs out
|
||||
* @arg {String} [options.expireGracePeriod] How long before the integration's role is removed from an unsubscribed user
|
||||
* @arg {String} [options.enableEmoticons] Whether to enable integration emoticons or not
|
||||
* @returns {Promise}
|
||||
*/
|
||||
edit(options) {
|
||||
return this.guild.shard.client.editGuildIntegration.call(this.guild.shard.client, this.guild.id, this.id, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Force the guild integration to sync
|
||||
* @returns {Promise}
|
||||
*/
|
||||
sync() {
|
||||
return this.guild.shard.client.syncGuildIntegration.call(this.guild.shard.client, this.guild.id, this.id);
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"account",
|
||||
"application",
|
||||
"enabled",
|
||||
"enableEmoticons",
|
||||
"expireBehavior",
|
||||
"expireGracePeriod",
|
||||
"name",
|
||||
"revoked",
|
||||
"roleID",
|
||||
"subscriberCount",
|
||||
"syncedAt",
|
||||
"syncing",
|
||||
"type",
|
||||
"user",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = GuildIntegration;
|
97
node_modules/eris/lib/structures/GuildPreview.js
generated
vendored
Normal file
97
node_modules/eris/lib/structures/GuildPreview.js
generated
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
"use strict";
|
||||
|
||||
const Base = require("./Base");
|
||||
const Endpoints = require("../rest/Endpoints.js");
|
||||
|
||||
/**
|
||||
* Represents a GuildPreview structure
|
||||
* @extends Base
|
||||
* @prop {Number} approximateMemberCount The **approximate** number of members in the guild
|
||||
* @prop {Number} approximatePresenceCount The **approximate** number of presences in the guild
|
||||
* @prop {String?} description The description for the guild (VIP only)
|
||||
* @prop {String?} discoverySplash The hash of the guild discovery splash image, or null if no splash
|
||||
* @prop {String?} discoverySplashURL The URL of the guild's discovery splash image
|
||||
* @prop {Array<Object>} emojis An array of guild emoji objects
|
||||
* @prop {Array<String>} features An array of guild feature strings
|
||||
* @prop {String?} icon The hash of the guild icon, or null if no icon
|
||||
* @prop {String?} iconURL The URL of the guild's icon
|
||||
* @prop {String} id The ID of the guild
|
||||
* @prop {String} name The name of the guild
|
||||
* @prop {String?} splash The hash of the guild splash image, or null if no splash (VIP only)
|
||||
* @prop {String?} splashURL The URL of the guild's splash image
|
||||
*/
|
||||
class GuildPreview extends Base {
|
||||
constructor(data, client) {
|
||||
super(data.id);
|
||||
this._client = client;
|
||||
|
||||
this.name = data.name;
|
||||
this.icon = data.icon;
|
||||
this.description = data.description;
|
||||
this.splash = data.splash;
|
||||
this.discoverySplash = data.discovery_splash;
|
||||
this.features = data.features;
|
||||
this.approximateMemberCount = data.approximate_member_count;
|
||||
this.approximatePresenceCount = data.approximate_presence_count;
|
||||
this.emojis = data.emojis;
|
||||
}
|
||||
|
||||
get iconURL() {
|
||||
return this.icon ? this._client._formatImage(Endpoints.GUILD_ICON(this.id, this.icon)) : null;
|
||||
}
|
||||
|
||||
get splashURL() {
|
||||
return this.splash ? this._client._formatImage(Endpoints.GUILD_SPLASH(this.id, this.splash)) : null;
|
||||
}
|
||||
|
||||
get discoverySplashURL() {
|
||||
return this.discoverySplash ? this._client._formatImage(Endpoints.GUILD_DISCOVERY_SPLASH(this.id, this.discoverySplash)) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the guild's splash with the given format and size
|
||||
* @arg {String} [format] The filetype of the icon ("jpg", "jpeg", "png", "gif", or "webp")
|
||||
* @arg {Number} [size] The size of the icon (any power of two between 16 and 4096)
|
||||
* @returns {String?}
|
||||
*/
|
||||
dynamicDiscoverySplashURL(format, size) {
|
||||
return this.discoverySplash ? this._client._formatImage(Endpoints.GUILD_DISCOVERY_SPLASH(this.id, this.discoverySplash), format, size) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the guild's icon with the given format and size
|
||||
* @arg {String} [format] The filetype of the icon ("jpg", "jpeg", "png", "gif", or "webp")
|
||||
* @arg {Number} [size] The size of the icon (any power of two between 16 and 4096)
|
||||
* @returns {String?}
|
||||
*/
|
||||
dynamicIconURL(format, size) {
|
||||
return this.icon ? this._client._formatImage(Endpoints.GUILD_ICON(this.id, this.icon), format, size) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the guild's splash with the given format and size
|
||||
* @arg {String} [format] The filetype of the icon ("jpg", "jpeg", "png", "gif", or "webp")
|
||||
* @arg {Number} [size] The size of the icon (any power of two between 16 and 4096)
|
||||
* @returns {String?}
|
||||
*/
|
||||
dynamicSplashURL(format, size) {
|
||||
return this.splash ? this._client._formatImage(Endpoints.GUILD_SPLASH(this.id, this.splash), format, size) : null;
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"approximateMemberCount",
|
||||
"approximatePresenceCount",
|
||||
"description",
|
||||
"discoverySplash",
|
||||
"emojis",
|
||||
"features",
|
||||
"icon",
|
||||
"name",
|
||||
"splash",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = GuildPreview;
|
156
node_modules/eris/lib/structures/GuildScheduledEvent.js
generated
vendored
Normal file
156
node_modules/eris/lib/structures/GuildScheduledEvent.js
generated
vendored
Normal file
@ -0,0 +1,156 @@
|
||||
"use strict";
|
||||
|
||||
const Base = require("./Base");
|
||||
const Endpoints = require("../rest/Endpoints");
|
||||
|
||||
/**
|
||||
* Represents a guild scheduled event
|
||||
* @prop {(VoiceChannel | StageChannel | Object)?} channel The channel where the event will be held. This will be null if the event is external (`entityType` is `3`). Can be partial with only `id` if the channel or guild is not cached
|
||||
* @prop {User?} creator The user that created the scheduled event. For events created before October 25 2021, this will be null. Please see the relevant Discord documentation for more details
|
||||
* @prop {String?} description The description of the event
|
||||
* @prop {String?} entityID The entity ID associated to the event
|
||||
* @prop {Object?} entityMetadata Metadata for the event. This will be null if the event is not external (`entityType` is not `3`)
|
||||
* @prop {String?} entityMetadata.location Location of the event
|
||||
* @prop {Number} entityType The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event
|
||||
* @prop {Guild | Object} guild The guild which the event belongs to. Can be partial with only `id` if not cached
|
||||
* @prop {String} id The id of the guild event
|
||||
* @prop {String?} image The hash of the event's image, or null if no image
|
||||
* @prop {String?} imageURL The URL of the event's image, or null if no image
|
||||
* @prop {String} name The name of the event
|
||||
* @prop {Number} privacyLevel Event privacy level
|
||||
* @prop {Number} scheduledStartTime The time the event will start
|
||||
* @prop {Number?} scheduledEndTime The time the event will end, or null if the event does not have a scheduled time to end
|
||||
* @prop {Number} status The [status](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status) of the scheduled event
|
||||
* @prop {Number?} userCount The number of users subscribed to the event
|
||||
*/
|
||||
class GuildScheduledEvent extends Base {
|
||||
constructor(data, client) {
|
||||
super(data.id);
|
||||
|
||||
this._client = client;
|
||||
if(data.creator !== undefined) {
|
||||
this.creator = client.users.update(data.creator, this.client);
|
||||
} else {
|
||||
this.creator = null;
|
||||
}
|
||||
this.guild = client.guilds.get(data.guild_id) || {
|
||||
id: data.guild_id
|
||||
};
|
||||
this.scheduledEndTime = null;
|
||||
this.update(data);
|
||||
}
|
||||
|
||||
update(data) {
|
||||
if(data.channel_id !== undefined) {
|
||||
if(data.channel_id !== null) {
|
||||
if(this._client.guilds.get(data.guild_id)) {
|
||||
this.channel = this._client.guilds.get(data.guild_id).channels.get(data.channel_id) || {id: data.channel_id};
|
||||
} else {
|
||||
this.channel = {id: data.channel_id};
|
||||
}
|
||||
} else {
|
||||
this.channel = null;
|
||||
}
|
||||
}
|
||||
if(data.name !== undefined) {
|
||||
this.name = data.name;
|
||||
}
|
||||
if(data.description !== undefined) {
|
||||
this.description = data.description;
|
||||
}
|
||||
if(data.scheduled_start_time !== undefined) {
|
||||
this.scheduledStartTime = Date.parse(data.scheduled_start_time);
|
||||
}
|
||||
if(data.scheduled_end_time !== undefined) {
|
||||
this.scheduledEndTime = Date.parse(data.scheduled_end_time);
|
||||
}
|
||||
if(data.privacy_level !== undefined) {
|
||||
this.privacyLevel = data.privacy_level;
|
||||
}
|
||||
if(data.status !== undefined) {
|
||||
this.status = data.status;
|
||||
}
|
||||
if(data.entity_type !== undefined) {
|
||||
this.entityType = data.entity_type;
|
||||
}
|
||||
if(data.entity_id !== undefined) {
|
||||
this.entityID = data.entity_id;
|
||||
}
|
||||
if(data.entity_metadata !== undefined) {
|
||||
this.entityMetadata = data.entity_metadata;
|
||||
}
|
||||
if(data.user_count !== undefined) {
|
||||
this.userCount = data.user_count;
|
||||
}
|
||||
if(data.image !== undefined) {
|
||||
this.image = data.image;
|
||||
}
|
||||
}
|
||||
|
||||
get imageURL() {
|
||||
return this.image ? this._client._formatImage(Endpoints.GUILD_SCHEDULED_EVENT_COVER(this.id, this.image)) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete this scheduled event
|
||||
* @returns {Promise}
|
||||
*/
|
||||
delete() {
|
||||
return this._client.deleteGuildScheduledEvent.call(this._client, this.guildID, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit this scheduled event
|
||||
* @arg {Object} event The new guild scheduled event object
|
||||
* @arg {String} [event.channelID] The channel ID of the event. If updating `entityType` to `3` (external), this **must** be set to `null`
|
||||
* @arg {String} [event.description] The description of the event
|
||||
* @arg {Object} [event.entityMetadata] The entity metadata for the scheduled event. This is required if updating `entityType` to `3` (external)
|
||||
* @arg {String} [event.entityMetadata.location] Location of the event. This is required if updating `entityType` to `3` (external)
|
||||
* @arg {Number} [event.entityType] The [entity type](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types) of the scheduled event
|
||||
* @arg {String} [event.image] Base 64 encoded image for the event
|
||||
* @arg {String} [event.name] The name of the event
|
||||
* @arg {String} [event.privacyLevel] The privacy level of the event
|
||||
* @arg {Date} [event.scheduledEndTime] The time when the scheduled event is scheduled to end. This is required if updating `entityType` to `3` (external)
|
||||
* @arg {Date} [event.scheduledStartTime] The time the event will start
|
||||
* @arg {Number} [event.status] The [status](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status) of the scheduled event
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise<GuildScheduledEvent>}
|
||||
*/
|
||||
edit(event, reason) {
|
||||
return this._client.editGuildScheduledEvent.call(this._client, this.guildID, this.id, event, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of users subscribed to the guild scheduled event
|
||||
* @arg {Object} [options] Options for the request
|
||||
* @arg {String} [options.after] Get users after this user ID. If `options.before` is provided, this will be ignored. Fetching users in between `before` and `after` is not supported
|
||||
* @arg {String} [options.before] Get users before this user ID
|
||||
* @arg {Number} [options.limit=100] The number of users to get (max 100). Pagination will only work if one of `options.after` or `options.after` is also provided
|
||||
* @arg {Boolean} [options.withMember] Include guild member data
|
||||
* @returns {Promise<Array<{guildScheduledEventID: String, member?: Member, user: User}>>}
|
||||
*/
|
||||
getUsers(options) {
|
||||
return this._client.getGuildScheduledEventUsers.call(this._client, this.guild.id, this.id, options);
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"channel",
|
||||
"creator",
|
||||
"description",
|
||||
"entityID",
|
||||
"entityMetadata",
|
||||
"entityType",
|
||||
"guild",
|
||||
"name",
|
||||
"privacyLevel",
|
||||
"scheduledEndTime",
|
||||
"scheduledStartTime",
|
||||
"status",
|
||||
"userCount",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = GuildScheduledEvent;
|
86
node_modules/eris/lib/structures/GuildTemplate.js
generated
vendored
Normal file
86
node_modules/eris/lib/structures/GuildTemplate.js
generated
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
const Base = require("./Base");
|
||||
const Guild = require("./Guild");
|
||||
|
||||
/**
|
||||
* Represents a guild template
|
||||
* @prop {String} code The template code
|
||||
* @prop {Number} createdAt Timestamp of template creation
|
||||
* @prop {User} creator User that created the template
|
||||
* @prop {String?} description The template description
|
||||
* @prop {Boolean?} isDirty Whether the template has unsynced changes
|
||||
* @prop {String} name The template name
|
||||
* @prop {Guild} serializedSourceGuild The guild snapshot this template contains
|
||||
* @prop {Guild | Object} sourceGuild The guild this template is based on. If the guild is not cached, this will be an object with `id` key. No other property is guaranteed
|
||||
* @prop {Number} updatedAt Timestamp of template update
|
||||
* @prop {Number} usageCount Number of times this template has been used
|
||||
*/
|
||||
class GuildTemplate {
|
||||
constructor(data, client) {
|
||||
this._client = client;
|
||||
this.code = data.code;
|
||||
this.createdAt = Date.parse(data.created_at);
|
||||
this.creator = client.users.update(data.creator, client);
|
||||
this.description = data.description;
|
||||
this.isDirty = data.is_dirty;
|
||||
this.name = data.name;
|
||||
this.serializedSourceGuild = new Guild(data.serialized_source_guild, client);
|
||||
this.sourceGuild = client.guilds.get(data.source_guild_id) || {id: data.source_guild_id};
|
||||
this.updatedAt = Date.parse(data.updated_at);
|
||||
this.usageCount = data.usage_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a guild based on this template. This can only be used with bots in less than 10 guilds
|
||||
* @arg {String} name The name of the guild
|
||||
* @arg {String} [icon] The 128x128 icon as a base64 data URI
|
||||
* @returns {Promise<Guild>}
|
||||
*/
|
||||
createGuild(name, icon) {
|
||||
return this._client.createGuildFromTemplate.call(this._client, this.code, name, icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete this template
|
||||
* @returns {Promise<GuildTemplate>}
|
||||
*/
|
||||
delete() {
|
||||
return this._client.deleteGuildTemplate.call(this._client, this.sourceGuild.id, this.code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit this template
|
||||
* @arg {Object} options The properties to edit
|
||||
* @arg {String} [options.name] The name of the template
|
||||
* @arg {String?} [options.description] The description for the template. Set to `null` to remove the description
|
||||
* @returns {Promise<GuildTemplate>}
|
||||
*/
|
||||
edit(options) {
|
||||
return this._client.editGuildTemplate.call(this._client, this.sourceGuild.id, this.code, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Force this template to sync to the guild's current state
|
||||
* @returns {Promise<GuildTemplate>}
|
||||
*/
|
||||
sync() {
|
||||
return this._client.syncGuildTemplate.call(this._client, this.sourceGuild.id, this.code);
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return Base.prototype.toJSON.call(this, [
|
||||
"code",
|
||||
"createdAt",
|
||||
"creator",
|
||||
"description",
|
||||
"isDirty",
|
||||
"name",
|
||||
"serializedSourceGuild",
|
||||
"sourceGuild",
|
||||
"updatedAt",
|
||||
"usageCount",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = GuildTemplate;
|
58
node_modules/eris/lib/structures/Interaction.js
generated
vendored
Normal file
58
node_modules/eris/lib/structures/Interaction.js
generated
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
|
||||
const Base = require("./Base");
|
||||
const {InteractionTypes} = require("../Constants");
|
||||
|
||||
/**
|
||||
* Represents an interaction. You also probably want to look at PingInteraction, CommandInteraction, ComponentInteraction, AutocompleteInteraction, and UnknownInteraction.
|
||||
* @prop {Boolean} acknowledged Whether or not the interaction has been acknowledged
|
||||
* @prop {String} applicationID The ID of the interaction's application
|
||||
* @prop {String} id The ID of the interaction
|
||||
* @prop {String} token The interaction token (Interaction tokens are valid for 15 minutes after initial response and can be used to send followup messages but you must send an initial response within 3 seconds of receiving the event. If the 3 second deadline is exceeded, the token will be invalidated.)
|
||||
* @prop {Number} type 1 is a Ping, 2 is an Application Command, 3 is a Message Component
|
||||
* @prop {Number} version The interaction version
|
||||
*/
|
||||
class Interaction extends Base {
|
||||
constructor(data, client) {
|
||||
super(data.id);
|
||||
this._client = client;
|
||||
|
||||
this.applicationID = data.application_id;
|
||||
this.token = data.token;
|
||||
this.type = data.type;
|
||||
this.version = data.version;
|
||||
this.acknowledged = false;
|
||||
}
|
||||
update() {
|
||||
this.acknowledged = true;
|
||||
}
|
||||
|
||||
static from(data, client) {
|
||||
switch(data.type) {
|
||||
case InteractionTypes.PING: {
|
||||
return new PingInteraction(data, client);
|
||||
}
|
||||
case InteractionTypes.APPLICATION_COMMAND: {
|
||||
return new CommandInteraction(data, client);
|
||||
}
|
||||
case InteractionTypes.MESSAGE_COMPONENT: {
|
||||
return new ComponentInteraction(data, client);
|
||||
}
|
||||
case InteractionTypes.APPLICATION_COMMAND_AUTOCOMPLETE: {
|
||||
return new AutocompleteInteraction(data, client);
|
||||
}
|
||||
}
|
||||
|
||||
client.emit("warn", new Error(`Unknown interaction type: ${data.type}\n${JSON.stringify(data)}`));
|
||||
return new UnknownInteraction(data, client);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Interaction;
|
||||
|
||||
// Circular import
|
||||
const PingInteraction = require("./PingInteraction");
|
||||
const CommandInteraction = require("./CommandInteraction");
|
||||
const ComponentInteraction = require("./ComponentInteraction");
|
||||
const AutocompleteInteraction = require("./AutocompleteInteraction");
|
||||
const UnknownInteraction = require("./UnknownInteraction");
|
109
node_modules/eris/lib/structures/Invite.js
generated
vendored
Normal file
109
node_modules/eris/lib/structures/Invite.js
generated
vendored
Normal file
@ -0,0 +1,109 @@
|
||||
"use strict";
|
||||
|
||||
const Base = require("./Base");
|
||||
const Guild = require("./Guild");
|
||||
|
||||
/**
|
||||
* Represents an invite. Some properties are only available when fetching invites from channels, which requires the Manage Channel permission.
|
||||
* @prop {TextChannel | NewsChannel | TextVoiceChannel | GroupChannel | StageChannel | Object} channel Info on the invite channel
|
||||
* @prop {String} channel.id The ID of the invite's channel
|
||||
* @prop {String?} channel.name The name of the invite's channel
|
||||
* @prop {Number} channel.type The type of the invite's channel
|
||||
* @prop {String?} channel.icon The icon of a channel (group dm)
|
||||
* @prop {String} code The invite code
|
||||
* @prop {Number?} createdAt Timestamp of invite creation
|
||||
* @prop {Guild?} guild Info on the invite guild
|
||||
* @prop {User?} inviter The invite creator
|
||||
* @prop {Number?} maxAge How long the invite lasts in seconds
|
||||
* @prop {Number?} maxUses The max number of invite uses
|
||||
* @prop {Number?} memberCount The **approximate** member count for the guild
|
||||
* @prop {Number?} presenceCount The **approximate** presence count for the guild
|
||||
* @prop {Object?} stageInstance The active public stage instance data for the stage channel this invite is for
|
||||
* @prop {String?} targetApplicationID The target application id
|
||||
* @prop {Number?} targetType The type of the target application
|
||||
* @prop {User?} targetUser The user whose stream is displayed for the invite (voice channel only)
|
||||
* @prop {Boolean?} temporary Whether the invite grants temporary membership or not
|
||||
* @prop {Number?} uses The number of invite uses
|
||||
*/
|
||||
class Invite extends Base {
|
||||
constructor(data, client) {
|
||||
super();
|
||||
this._client = client;
|
||||
this.code = data.code;
|
||||
if(data.guild && client.guilds.has(data.guild.id)) {
|
||||
this.channel = client.guilds.get(data.guild.id).channels.update(data.channel, client);
|
||||
} else {
|
||||
this.channel = data.channel;
|
||||
}
|
||||
if(data.guild) {
|
||||
if(client.guilds.has(data.guild.id)) {
|
||||
this.guild = client.guilds.update(data.guild, client);
|
||||
} else {
|
||||
this.guild = new Guild(data.guild, client);
|
||||
}
|
||||
}
|
||||
if(data.inviter) {
|
||||
this.inviter = client.users.add(data.inviter, client);
|
||||
}
|
||||
this.uses = data.uses !== undefined ? data.uses : null;
|
||||
this.maxUses = data.max_uses !== undefined ? data.max_uses : null;
|
||||
this.maxAge = data.max_age !== undefined ? data.max_age : null;
|
||||
this.temporary = data.temporary !== undefined ? data.temporary : null;
|
||||
this._createdAt = data.created_at !== undefined ? data.created_at : null;
|
||||
this.presenceCount = data.approximate_presence_count !== undefined ? data.approximate_presence_count : null;
|
||||
this.memberCount = data.approximate_member_count !== undefined ? data.approximate_member_count : null;
|
||||
if(data.stage_instance !== undefined) {
|
||||
data.stage_instance.members = data.stage_instance.members.map((m) => {
|
||||
m.id = m.user.id;
|
||||
return m;
|
||||
});
|
||||
this.stageInstance = {
|
||||
members: data.stage_instance.members.map((m) => this.guild.members.update(m, this.guild)),
|
||||
participantCount: data.stage_instance.participant_count,
|
||||
speakerCount: data.stage_instance.speaker_count,
|
||||
topic: data.stage_instance.topic
|
||||
};
|
||||
} else {
|
||||
this.stageInstance = null;
|
||||
}
|
||||
this.targetApplicationID = data.target_application !== undefined ? data.target_application.id : null;
|
||||
this.targetType = data.target_type !== undefined ? data.target_type : null;
|
||||
this.targetUser = data.target_user !== undefined ? this._client.users.update(data.target_user, this._client) : null;
|
||||
}
|
||||
|
||||
get createdAt() {
|
||||
return Date.parse(this._createdAt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the invite
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise}
|
||||
*/
|
||||
delete(reason) {
|
||||
return this._client.deleteInvite.call(this._client, this.code, reason);
|
||||
}
|
||||
|
||||
toString() {
|
||||
return `[Invite ${this.code}]`;
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"channel",
|
||||
"code",
|
||||
"createdAt",
|
||||
"guild",
|
||||
"maxAge",
|
||||
"maxUses",
|
||||
"memberCount",
|
||||
"presenceCount",
|
||||
"revoked",
|
||||
"temporary",
|
||||
"uses",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Invite;
|
287
node_modules/eris/lib/structures/Member.js
generated
vendored
Normal file
287
node_modules/eris/lib/structures/Member.js
generated
vendored
Normal file
@ -0,0 +1,287 @@
|
||||
"use strict";
|
||||
|
||||
const Base = require("./Base");
|
||||
const Endpoints = require("../rest/Endpoints");
|
||||
const User = require("./User");
|
||||
const VoiceState = require("./VoiceState");
|
||||
|
||||
/**
|
||||
* Represents a server member
|
||||
* @prop {Number?} accentColor The user's banner color, or null if no banner color (REST only)
|
||||
* @prop {Array<Object>?} activities The member's current activities
|
||||
* @prop {String?} avatar The hash of the member's guild avatar, or null if no guild avatar
|
||||
* @prop {String} avatarURL The URL of the user's avatar which can be either a JPG or GIF
|
||||
* @prop {String?} banner The hash of the user's banner, or null if no banner (REST only)
|
||||
* @prop {String?} bannerURL The URL of the user's banner
|
||||
* @prop {Boolean} bot Whether the user is an OAuth bot or not
|
||||
* @prop {Object?} clientStatus The member's per-client status
|
||||
* @prop {String} clientStatus.web The member's status on web. Either "online", "idle", "dnd", or "offline". Will be "online" for bots
|
||||
* @prop {String} clientStatus.desktop The member's status on desktop. Either "online", "idle", "dnd", or "offline". Will be "offline" for bots
|
||||
* @prop {String} clientStatus.mobile The member's status on mobile. Either "online", "idle", "dnd", or "offline". Will be "offline" for bots
|
||||
* @prop {Number?} communicationDisabledUntil Timestamp of timeout expiry. If `null`, the member is not timed out
|
||||
* @prop {Number} createdAt Timestamp of user creation
|
||||
* @prop {String} defaultAvatar The hash for the default avatar of a user if there is no avatar set
|
||||
* @prop {String} defaultAvatarURL The URL of the user's default avatar
|
||||
* @prop {String} discriminator The discriminator of the user
|
||||
* @prop {Object?} game The active game the member is playing
|
||||
* @prop {String} game.name The name of the active game
|
||||
* @prop {Number} game.type The type of the active game (0 is default, 1 is Twitch, 2 is YouTube)
|
||||
* @prop {String?} game.url The url of the active game
|
||||
* @prop {Guild} guild The guild the member is in
|
||||
* @prop {String} id The ID of the member
|
||||
* @prop {Number?} joinedAt Timestamp of when the member joined the guild
|
||||
* @prop {String} mention A string that mentions the member
|
||||
* @prop {String?} nick The server nickname of the member
|
||||
* @prop {Boolean?} pending Whether the member has passed the guild's Membership Screening requirements
|
||||
* @prop {Permission} permission [DEPRECATED] The guild-wide permissions of the member. Use Member#permissions instead
|
||||
* @prop {Permission} permissions The guild-wide permissions of the member
|
||||
* @prop {Number?} premiumSince Timestamp of when the member boosted the guild
|
||||
* @prop {Array<String>} roles An array of role IDs this member is a part of
|
||||
* @prop {String} staticAvatarURL The URL of the user's avatar (always a JPG)
|
||||
* @prop {String} status The member's status. Either "online", "idle", "dnd", or "offline"
|
||||
* @prop {User} user The user object of the member
|
||||
* @prop {String} username The username of the user
|
||||
* @prop {VoiceState} voiceState The voice state of the member
|
||||
*/
|
||||
class Member extends Base {
|
||||
constructor(data, guild, client) {
|
||||
super(data.id || data.user.id);
|
||||
if(!data.id && data.user) {
|
||||
data.id = data.user.id;
|
||||
}
|
||||
if((this.guild = guild)) {
|
||||
this.user = guild.shard.client.users.get(data.id);
|
||||
if(!this.user && data.user) {
|
||||
this.user = guild.shard.client.users.add(data.user, guild.shard.client);
|
||||
}
|
||||
if(!this.user) {
|
||||
throw new Error("User associated with Member not found: " + data.id);
|
||||
}
|
||||
} else if(data.user) {
|
||||
if(!client) {
|
||||
this.user = new User(data.user);
|
||||
} else {
|
||||
this.user = client.users.update(data.user, client);
|
||||
}
|
||||
} else {
|
||||
this.user = null;
|
||||
}
|
||||
|
||||
this.nick = null;
|
||||
this.roles = [];
|
||||
this.update(data);
|
||||
}
|
||||
|
||||
update(data) {
|
||||
if(data.status !== undefined) {
|
||||
this.status = data.status;
|
||||
}
|
||||
if(data.joined_at !== undefined) {
|
||||
this.joinedAt = data.joined_at ? Date.parse(data.joined_at) : null;
|
||||
}
|
||||
if(data.client_status !== undefined) {
|
||||
this.clientStatus = Object.assign({web: "offline", desktop: "offline", mobile: "offline"}, data.client_status);
|
||||
}
|
||||
if(data.activities !== undefined) {
|
||||
this.activities = data.activities;
|
||||
}
|
||||
if(data.premium_since !== undefined) {
|
||||
this.premiumSince = data.premium_since === null ? null : Date.parse(data.premium_since);
|
||||
}
|
||||
if(data.hasOwnProperty("mute") && this.guild) {
|
||||
const state = this.guild.voiceStates.get(this.id);
|
||||
if(data.channel_id === null && !data.mute && !data.deaf && !data.suppress) {
|
||||
this.guild.voiceStates.delete(this.id);
|
||||
} else if(state) {
|
||||
state.update(data);
|
||||
} else if(data.channel_id || data.mute || data.deaf || data.suppress) {
|
||||
this.guild.voiceStates.update(data);
|
||||
}
|
||||
}
|
||||
if(data.nick !== undefined) {
|
||||
this.nick = data.nick;
|
||||
}
|
||||
if(data.roles !== undefined) {
|
||||
this.roles = data.roles;
|
||||
}
|
||||
if(data.pending !== undefined) {
|
||||
this.pending = data.pending;
|
||||
}
|
||||
if(data.avatar !== undefined) {
|
||||
this.avatar = data.avatar;
|
||||
}
|
||||
if(data.communication_disabled_until !== undefined) {
|
||||
if(data.communication_disabled_until !== null) {
|
||||
this.communicationDisabledUntil = Date.parse(data.communication_disabled_until);
|
||||
} else {
|
||||
this.communicationDisabledUntil = data.communication_disabled_until;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get accentColor() {
|
||||
return this.user.accentColor;
|
||||
}
|
||||
|
||||
get avatarURL() {
|
||||
return this.avatar ? this.guild.shard.client._formatImage(Endpoints.GUILD_AVATAR(this.guild.id, this.id, this.avatar)) : this.user.avatarURL;
|
||||
}
|
||||
|
||||
get banner() {
|
||||
return this.user.banner;
|
||||
}
|
||||
|
||||
get bannerURL() {
|
||||
return this.user.bannerURL;
|
||||
}
|
||||
|
||||
get bot() {
|
||||
return this.user.bot;
|
||||
}
|
||||
|
||||
get createdAt() {
|
||||
return this.user.createdAt;
|
||||
}
|
||||
|
||||
get defaultAvatar() {
|
||||
return this.user.defaultAvatar;
|
||||
}
|
||||
|
||||
get defaultAvatarURL() {
|
||||
return this.user.defaultAvatarURL;
|
||||
}
|
||||
|
||||
get discriminator() {
|
||||
return this.user.discriminator;
|
||||
}
|
||||
|
||||
get mention() {
|
||||
return `<@!${this.id}>`;
|
||||
}
|
||||
|
||||
get permission() {
|
||||
this.guild.shard.client.emit("warn", "[DEPRECATED] Member#permission is deprecated. Use Member#permissions instead");
|
||||
return this.permissions;
|
||||
}
|
||||
|
||||
get permissions() {
|
||||
return this.guild.permissionsOf(this);
|
||||
}
|
||||
|
||||
get staticAvatarURL(){
|
||||
return this.user.staticAvatarURL;
|
||||
}
|
||||
|
||||
get username() {
|
||||
return this.user.username;
|
||||
}
|
||||
|
||||
get voiceState() {
|
||||
if(this.guild && this.guild.voiceStates.has(this.id)) {
|
||||
return this.guild.voiceStates.get(this.id);
|
||||
} else {
|
||||
return new VoiceState({
|
||||
id: this.id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
get game() {
|
||||
return this.activities && this.activities.length > 0 ? this.activities[0] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a role to the guild member
|
||||
* @arg {String} roleID The ID of the role
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise}
|
||||
*/
|
||||
addRole(roleID, reason) {
|
||||
return this.guild.shard.client.addGuildMemberRole.call(this.guild.shard.client, this.guild.id, this.id, roleID, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ban the user from the guild
|
||||
* @arg {Number} [deleteMessageDays=0] Number of days to delete messages for, between 0-7 inclusive
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise}
|
||||
*/
|
||||
ban(deleteMessageDays, reason) {
|
||||
return this.guild.shard.client.banGuildMember.call(this.guild.shard.client, this.guild.id, this.id, deleteMessageDays, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the member's avatar with the given format and size
|
||||
* @arg {String} [format] The filetype of the avatar ("jpg", "jpeg", "png", "gif", or "webp")
|
||||
* @arg {Number} [size] The size of the avatar (any power of two between 16 and 4096)
|
||||
* @returns {String}
|
||||
*/
|
||||
dynamicAvatarURL(format, size) {
|
||||
if(!this.avatar) {
|
||||
return this.user.dynamicAvatarURL(format, size);
|
||||
}
|
||||
return this.guild.shard.client._formatImage(Endpoints.GUILD_AVATAR(this.guild.id, this.id, this.avatar), format, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit the guild member
|
||||
* @arg {Object} options The properties to edit
|
||||
* @arg {String?} [options.channelID] The ID of the voice channel to move the member to (must be in voice). Set to `null` to disconnect the member
|
||||
* @arg {Date?} [options.communicationDisabledUntil] When the user's timeout should expire. Set to `null` to instantly remove timeout
|
||||
* @arg {Boolean} [options.deaf] Server deafen the user
|
||||
* @arg {Boolean} [options.mute] Server mute the user
|
||||
* @arg {String} [options.nick] Set the user's server nickname, "" to remove
|
||||
* @arg {Array<String>} [options.roles] The array of role IDs the user should have
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise}
|
||||
*/
|
||||
edit(options, reason) {
|
||||
return this.guild.shard.client.editGuildMember.call(this.guild.shard.client, this.guild.id, this.id, options, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Kick the member from the guild
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise}
|
||||
*/
|
||||
kick(reason) {
|
||||
return this.guild.shard.client.kickGuildMember.call(this.guild.shard.client, this.guild.id, this.id, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a role from the guild member
|
||||
* @arg {String} roleID The ID of the role
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise}
|
||||
*/
|
||||
removeRole(roleID, reason) {
|
||||
return this.guild.shard.client.removeGuildMemberRole.call(this.guild.shard.client, this.guild.id, this.id, roleID, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unban the user from the guild
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise}
|
||||
*/
|
||||
unban(reason) {
|
||||
return this.guild.shard.client.unbanGuildMember.call(this.guild.shard.client, this.guild.id, this.id, reason);
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"activities",
|
||||
"communicationDisabledUntil",
|
||||
"joinedAt",
|
||||
"nick",
|
||||
"pending",
|
||||
"premiumSince",
|
||||
"roles",
|
||||
"status",
|
||||
"user",
|
||||
"voiceState",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Member;
|
632
node_modules/eris/lib/structures/Message.js
generated
vendored
Normal file
632
node_modules/eris/lib/structures/Message.js
generated
vendored
Normal file
@ -0,0 +1,632 @@
|
||||
"use strict";
|
||||
|
||||
const Base = require("./Base");
|
||||
const Endpoints = require("../rest/Endpoints");
|
||||
const Call = require("./Call");
|
||||
const {SystemJoinMessages, MessageTypes, MessageFlags} = require("../Constants");
|
||||
const User = require("./User");
|
||||
|
||||
/**
|
||||
* Represents a message
|
||||
* @prop {Object?} activity The activity specified in the message
|
||||
* @prop {Object?} application The application of the activity in the message
|
||||
* @prop {String?} applicationID The ID of the interaction's application
|
||||
* @prop {Array<Object>} attachments Array of attachments
|
||||
* @prop {User} author The message author
|
||||
* @prop {PrivateChannel | TextChannel | NewsChannel} channel The channel the message is in. Can be partial with only the id if the channel is not cached.
|
||||
* @prop {Array<String>} channelMentions Array of mentions channels' ids
|
||||
* @prop {String?} cleanContent Message content with mentions replaced by names. Mentions are currently escaped, but this behavior is [DEPRECATED] and will be removed soon. Use allowed mentions, the official way of avoiding unintended mentions, when creating messages.
|
||||
* @prop {Command?} command The Command used in the Message, if any (CommandClient only)
|
||||
* @prop {Array<Object>} components An array of component objects
|
||||
* @prop {String} content Message content
|
||||
* @prop {Number} createdAt Timestamp of message creation
|
||||
* @prop {Number?} editedTimestamp Timestamp of latest message edit
|
||||
* @prop {Array<Object>} embeds Array of embeds
|
||||
* @prop {Number} flags Message flags (see constants)
|
||||
* @prop {String} [guildID] The ID of the guild this message is in (undefined if in DMs)
|
||||
* @prop {String} id The ID of the message
|
||||
* @prop {String} jumpLink The url used by Discord clients to jump to this message
|
||||
* @prop {Member?} member The message author with server-specific data
|
||||
* @prop {Boolean} mentionEveryone Whether the message mentions everyone/here or not
|
||||
* @prop {Array<User>} mentions Array of mentioned users
|
||||
* @prop {Object?} messageReference An object containing the reference to the original message if it is a crossposted message or reply
|
||||
* @prop {String?} messageReference.messageID The id of the original message this message was crossposted from
|
||||
* @prop {String} messageReference.channelID The id of the channel this message was crossposted from
|
||||
* @prop {String?} messageReference.guildID The id of the guild this message was crossposted from
|
||||
* @prop {Object?} interaction An object containing info about the interaction the message is responding to, if applicable
|
||||
* @prop {String} interaction.id The id of the interaction
|
||||
* @prop {Number} interaction.type The type of interaction
|
||||
* @prop {String} interaction.name The name of the command
|
||||
* @prop {User} interaction.user The user who invoked the interaction
|
||||
* @prop {Member?} interaction.member The member who invoked the interaction
|
||||
* @prop {Boolean} pinned Whether the message is pinned or not
|
||||
* @prop {String?} prefix The prefix used in the Message, if any (CommandClient only)
|
||||
* @prop {Object} reactions An object containing the reactions on the message. Each key is a reaction emoji and each value is an object with properties `me` (Boolean) and `count` (Number) for that specific reaction emoji.
|
||||
* @prop {Message?} referencedMessage The message that was replied to. If undefined, message data was not received. If null, the message was deleted.
|
||||
* @prop {Array<String>} roleMentions Array of mentioned roles' ids
|
||||
* @prop {Array<Object>?} stickers [DEPRECATED] The stickers sent with the message
|
||||
* @prop {Array<Object>?} stickerItems The stickers sent with the message
|
||||
* @prop {Number} timestamp Timestamp of message creation
|
||||
* @prop {Boolean} tts Whether to play the message using TTS or not
|
||||
* @prop {Number} type The type of the message
|
||||
* @prop {String?} webhookID ID of the webhook that sent the message
|
||||
*/
|
||||
class Message extends Base {
|
||||
constructor(data, client) {
|
||||
super(data.id);
|
||||
this._client = client;
|
||||
this.type = data.type || 0;
|
||||
this.timestamp = Date.parse(data.timestamp);
|
||||
this.channel = this._client.getChannel(data.channel_id) || {
|
||||
id: data.channel_id
|
||||
};
|
||||
this.content = "";
|
||||
this.hit = !!data.hit;
|
||||
this.reactions = {};
|
||||
this.guildID = data.guild_id;
|
||||
this.webhookID = data.webhook_id;
|
||||
|
||||
if(data.message_reference) {
|
||||
this.messageReference = {
|
||||
messageID: data.message_reference.message_id,
|
||||
channelID: data.message_reference.channel_id,
|
||||
guildID: data.message_reference.guild_id
|
||||
};
|
||||
} else {
|
||||
this.messageReference = null;
|
||||
}
|
||||
|
||||
this.flags = data.flags || 0;
|
||||
|
||||
if(data.author) {
|
||||
if(data.author.discriminator !== "0000") {
|
||||
this.author = this._client.users.update(data.author, client);
|
||||
} else {
|
||||
this.author = new User(data.author, client);
|
||||
}
|
||||
} else {
|
||||
this._client.emit("error", new Error("MESSAGE_CREATE but no message author:\n" + JSON.stringify(data, null, 2)));
|
||||
}
|
||||
if(data.referenced_message) {
|
||||
const channel = this._client.getChannel(data.referenced_message.channel_id);
|
||||
if(channel) {
|
||||
this.referencedMessage = channel.messages.update(data.referenced_message, this._client);
|
||||
} else {
|
||||
this.referencedMessage = new Message(data.referenced_message, this._client);
|
||||
}
|
||||
} else {
|
||||
this.referencedMessage = data.referenced_message;
|
||||
}
|
||||
|
||||
if(data.interaction) {
|
||||
this.interaction = data.interaction;
|
||||
let interactionMember;
|
||||
const interactionUser = this._client.users.update(data.interaction.user, client);
|
||||
if(data.interaction.member) {
|
||||
data.interaction.member.id = data.interaction.user.id;
|
||||
if(this.channel.guild) {
|
||||
interactionMember = this.channel.guild.members.update(data.interaction.member, this.channel.guild);
|
||||
} else {
|
||||
interactionMember = data.interaction.member;
|
||||
}
|
||||
} else if(this.channel.guild && this.channel.guild.members.has(data.interaction.user.id)) {
|
||||
interactionMember = this.channel.guild.members.get(data.interaction.user.id);
|
||||
} else {
|
||||
interactionMember = null;
|
||||
}
|
||||
this.interaction.user = interactionUser;
|
||||
this.interaction.member = interactionMember;
|
||||
} else {
|
||||
this.interaction = null;
|
||||
}
|
||||
|
||||
if(this.channel.guild) {
|
||||
if(data.member) {
|
||||
data.member.id = this.author.id;
|
||||
if(data.author) {
|
||||
data.member.user = data.author;
|
||||
}
|
||||
this.member = this.channel.guild.members.update(data.member, this.channel.guild);
|
||||
} else if(this.channel.guild.members.has(this.author.id)) {
|
||||
this.member = this.channel.guild.members.get(this.author.id);
|
||||
} else {
|
||||
this.member = null;
|
||||
}
|
||||
|
||||
if(!this.guildID) {
|
||||
this.guildID = this.channel.guild.id;
|
||||
}
|
||||
} else {
|
||||
this.member = null;
|
||||
}
|
||||
|
||||
switch(this.type) {
|
||||
case MessageTypes.DEFAULT: {
|
||||
break;
|
||||
}
|
||||
case MessageTypes.RECIPIENT_ADD: {
|
||||
data.content = `${this.author.mention} added <@${data.mentions[0].id}>.`;
|
||||
break;
|
||||
}
|
||||
case MessageTypes.RECIPIENT_REMOVE: {
|
||||
if(this.author.id === data.mentions[0].id) {
|
||||
data.content = `@${this.author.username} left the group.`;
|
||||
} else {
|
||||
data.content = `${this.author.mention} removed @${data.mentions[0].username}.`;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MessageTypes.CALL: {
|
||||
if(data.call.ended_timestamp) {
|
||||
if((!this.channel.lastCall || this.channel.lastCall.endedTimestamp < Date.parse(data.call.ended_timestamp))) {
|
||||
data.call.id = this.id;
|
||||
this.channel.lastCall = new Call(data.call, this.channel);
|
||||
}
|
||||
if(data.call.participants.includes(this._client.user.id)) {
|
||||
data.content = `You missed a call from ${this.author.mention}.`;
|
||||
} else {
|
||||
data.content = `${this.author.mention} started a call.`;
|
||||
}
|
||||
} else {
|
||||
if(!this.channel.call) {
|
||||
data.call.id = this.id;
|
||||
this.channel.call = new Call(data.call, this.channel);
|
||||
}
|
||||
data.content = `${this.author.mention} started a call. — Join the call.`;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MessageTypes.CHANNEL_NAME_CHANGE: {
|
||||
data.content = `${this.author.mention} changed the channel name: ${data.content}`;
|
||||
break;
|
||||
}
|
||||
case MessageTypes.CHANNEL_ICON_CHANGE: {
|
||||
data.content = `${this.author.mention} changed the channel icon.`;
|
||||
break;
|
||||
}
|
||||
case MessageTypes.CHANNEL_PINNED_MESSAGE: {
|
||||
data.content = `${this.author.mention} pinned a message to this channel. See all the pins.`;
|
||||
break;
|
||||
}
|
||||
case MessageTypes.GUILD_MEMBER_JOIN: {
|
||||
data.content = SystemJoinMessages[~~(this.createdAt % SystemJoinMessages.length)].replace(/%user%/g, this.author.mention);
|
||||
break;
|
||||
}
|
||||
case MessageTypes.USER_PREMIUM_GUILD_SUBSCRIPTION: {
|
||||
data.content = `${this.author.mention} just boosted the server!`;
|
||||
break;
|
||||
}
|
||||
case MessageTypes.USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1:
|
||||
case MessageTypes.USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2:
|
||||
case MessageTypes.USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3: {
|
||||
data.content = `${this.author.mention} just boosted the server! ${this.channel.guild ? this.channel.guild.name : data.guild_id} has achieved **Level ${this.type - 8}!**`;
|
||||
break;
|
||||
}
|
||||
case MessageTypes.CHANNEL_FOLLOW_ADD: {
|
||||
data.content = `${this.author.mention} has added ${data.content} to this channel`;
|
||||
break;
|
||||
}
|
||||
case MessageTypes.GUILD_DISCOVERY_DISQUALIFIED: {
|
||||
data.content = "This server has been removed from Server Discovery because it no longer passes all the requirements. Check `Server Settings` for more details.";
|
||||
break;
|
||||
}
|
||||
case MessageTypes.GUILD_DISCOVERY_REQUALIFIED: {
|
||||
data.content = "This server is eligible for Server Discovery again and has been automatically relisted!";
|
||||
break;
|
||||
}
|
||||
case MessageTypes.GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING: {
|
||||
data.content = "This server has failed Discovery activity requirements for 1 week. If this server fails for 4 weeks in a row, it will be automatically removed from Discovery.";
|
||||
break;
|
||||
}
|
||||
case MessageTypes.GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING: {
|
||||
data.content = "This server has failed Discovery activity requirements for 3 weeks in a row. If this server fails for 1 more week, it will be removed from Discovery.";
|
||||
break;
|
||||
}
|
||||
case MessageTypes.THREAD_CREATED: {
|
||||
break;
|
||||
}
|
||||
case MessageTypes.REPLY: {
|
||||
break;
|
||||
}
|
||||
case MessageTypes.CHAT_INPUT_COMMAND: {
|
||||
break;
|
||||
}
|
||||
case MessageTypes.CONTEXT_MENU_COMMAND: {
|
||||
break;
|
||||
}
|
||||
case MessageTypes.THREAD_STARTER_MESSAGE: {
|
||||
break;
|
||||
}
|
||||
case MessageTypes.GUILD_INVITE_REMINDER: {
|
||||
data.content = "Wondering who to invite?\nStart by inviting anyone who can help you build the server!";
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
this._client.emit("warn", `Unhandled MESSAGE_CREATE type: ${JSON.stringify(data, null, 2)}`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.update(data, client);
|
||||
}
|
||||
|
||||
update(data, client) {
|
||||
if(this.type === 3) { // (╯°□°)╯︵ ┻━┻
|
||||
(this.channel.call || this.channel.lastCall).update(data.call);
|
||||
}
|
||||
if(data.content !== undefined) {
|
||||
this.content = data.content || "";
|
||||
this.mentionEveryone = !!data.mention_everyone;
|
||||
|
||||
this.mentions = data.mentions.map((mention) => {
|
||||
const user = this._client.users.add(mention, client);
|
||||
if(mention.member && this.channel.guild) {
|
||||
mention.member.id = mention.id;
|
||||
this.channel.guild.members.update(mention.member, this.channel.guild);
|
||||
}
|
||||
return user;
|
||||
});
|
||||
|
||||
this.roleMentions = data.mention_roles;
|
||||
}
|
||||
|
||||
if(data.pinned !== undefined) {
|
||||
this.pinned = !!data.pinned;
|
||||
}
|
||||
if(data.edited_timestamp != undefined) {
|
||||
this.editedTimestamp = Date.parse(data.edited_timestamp);
|
||||
}
|
||||
if(data.tts !== undefined) {
|
||||
this.tts = data.tts;
|
||||
}
|
||||
if(data.attachments !== undefined) {
|
||||
this.attachments = data.attachments;
|
||||
}
|
||||
if(data.embeds !== undefined) {
|
||||
this.embeds = data.embeds;
|
||||
}
|
||||
if(data.flags !== undefined) {
|
||||
this.flags = data.flags;
|
||||
}
|
||||
if(data.activity !== undefined) {
|
||||
this.activity = data.activity;
|
||||
}
|
||||
if(data.application !== undefined) {
|
||||
this.application = data.application;
|
||||
}
|
||||
if(data.application_id !== undefined) {
|
||||
this.applicationID = data.application_id;
|
||||
}
|
||||
|
||||
if(data.reactions) {
|
||||
data.reactions.forEach((reaction) => {
|
||||
this.reactions[reaction.emoji.id ? `${reaction.emoji.name}:${reaction.emoji.id}` : reaction.emoji.name] = {
|
||||
count: reaction.count,
|
||||
me: reaction.me
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
if(data.stickers !== undefined) {
|
||||
this.stickers = data.stickers;
|
||||
}
|
||||
|
||||
if(data.sticker_items !== undefined) {
|
||||
this.stickerItems = data.sticker_items.map((sticker) => {
|
||||
if(sticker.user) {
|
||||
sticker.user = this._client.users.update(sticker.user, client);
|
||||
}
|
||||
|
||||
return sticker;
|
||||
});
|
||||
}
|
||||
|
||||
if(data.components !== undefined) {
|
||||
this.components = data.components;
|
||||
}
|
||||
}
|
||||
|
||||
get channelMentions() {
|
||||
if(this._channelMentions) {
|
||||
return this._channelMentions;
|
||||
}
|
||||
|
||||
return (this._channelMentions = (this.content && this.content.match(/<#[0-9]+>/g) || []).map((mention) => mention.substring(2, mention.length - 1)));
|
||||
}
|
||||
|
||||
get cleanContent() {
|
||||
let cleanContent = this.content && this.content.replace(/<a?(:\w+:)[0-9]+>/g, "$1") || "";
|
||||
|
||||
let authorName = this.author.username;
|
||||
if(this.channel.guild) {
|
||||
const member = this.channel.guild.members.get(this.author.id);
|
||||
if(member && member.nick) {
|
||||
authorName = member.nick;
|
||||
}
|
||||
}
|
||||
cleanContent = cleanContent.replace(new RegExp(`<@!?${this.author.id}>`, "g"), "@\u200b" + authorName);
|
||||
|
||||
if(this.mentions) {
|
||||
this.mentions.forEach((mention) => {
|
||||
if(this.channel.guild) {
|
||||
const member = this.channel.guild.members.get(mention.id);
|
||||
if(member && member.nick) {
|
||||
cleanContent = cleanContent.replace(new RegExp(`<@!?${mention.id}>`, "g"), "@\u200b" + member.nick);
|
||||
}
|
||||
}
|
||||
cleanContent = cleanContent.replace(new RegExp(`<@!?${mention.id}>`, "g"), "@\u200b" + mention.username);
|
||||
});
|
||||
}
|
||||
|
||||
if(this.channel.guild && this.roleMentions) {
|
||||
for(const roleID of this.roleMentions) {
|
||||
const role = this.channel.guild.roles.get(roleID);
|
||||
const roleName = role ? role.name : "deleted-role";
|
||||
cleanContent = cleanContent.replace(new RegExp(`<@&${roleID}>`, "g"), "@\u200b" + roleName);
|
||||
}
|
||||
}
|
||||
|
||||
this.channelMentions.forEach((id) => {
|
||||
const channel = this._client.getChannel(id);
|
||||
if(channel && channel.name && channel.mention) {
|
||||
cleanContent = cleanContent.replace(channel.mention, "#" + channel.name);
|
||||
}
|
||||
});
|
||||
|
||||
return cleanContent.replace(/@everyone/g, "@\u200beveryone").replace(/@here/g, "@\u200bhere");
|
||||
}
|
||||
|
||||
get jumpLink() {
|
||||
return `${Endpoints.CLIENT_URL}${Endpoints.MESSAGE_LINK(this.guildID || "@me", this.channel.id, this.id)}`; // Messages outside of guilds (DMs) will never have a guildID property assigned
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a reaction to a message
|
||||
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
||||
* @arg {String} [userID="@me"] The ID of the user to react as. Passing this parameter is deprecated and will not be supported in future versions.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
addReaction(reaction, userID) {
|
||||
if(this.flags & MessageFlags.EPHEMERAL) {
|
||||
throw new Error("Ephemeral messages cannot have reactions");
|
||||
}
|
||||
return this._client.addMessageReaction.call(this._client, this.channel.id, this.id, reaction, userID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a thread with this message
|
||||
* @arg {Object} options The thread options
|
||||
* @arg {Number} options.autoArchiveDuration Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080
|
||||
* @arg {String} options.name The thread channel name
|
||||
* @returns {Promise<NewsThreadChannel | PublicThreadChannel>}
|
||||
*/
|
||||
createThreadWithMessage(options) {
|
||||
return this._client.createThreadWithMessage.call(this._client, this.channel.id, this.id, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Crosspost (publish) a message to subscribed channels (NewsChannel only)
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
crosspost() {
|
||||
if(this.flags & MessageFlags.EPHEMERAL) {
|
||||
throw new Error("Ephemeral messages cannot be crossposted");
|
||||
}
|
||||
return this._client.crosspostMessage.call(this._client, this.channel.id, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the message
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise}
|
||||
*/
|
||||
delete(reason) {
|
||||
if(this.flags & MessageFlags.EPHEMERAL) {
|
||||
throw new Error("Ephemeral messages cannot be deleted");
|
||||
}
|
||||
return this._client.deleteMessage.call(this._client, this.channel.id, this.id, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the message as a webhook
|
||||
* @arg {String} token The token of the webhook
|
||||
* @returns {Promise}
|
||||
*/
|
||||
deleteWebhook(token) {
|
||||
if(!this.webhookID) {
|
||||
throw new Error("Message is not a webhook");
|
||||
}
|
||||
if(this.flags & MessageFlags.EPHEMERAL) {
|
||||
throw new Error("Ephemeral messages cannot be deleted");
|
||||
}
|
||||
return this._client.deleteWebhookMessage.call(this._client, this.webhookID, token, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit the message
|
||||
* @arg {String | Array | Object} content A string, array of strings, or object. If an object is passed:
|
||||
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
||||
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
|
||||
* @arg {Array<Object>} [content.components] An array of component objects
|
||||
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 0-4 and type 3 only)
|
||||
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3 only)
|
||||
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
||||
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
||||
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
||||
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
||||
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
||||
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
||||
* @arg {String} [content.components[].options[].description] The description for this option
|
||||
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
||||
* @arg {String} content.components[].options[].label The label for this option
|
||||
* @arg {Number | String} content.components[].options[].value The value for this option
|
||||
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3 only)
|
||||
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
|
||||
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
|
||||
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
||||
* @arg {String} [content.content] A content string
|
||||
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Object | Array<Object>} [content.file] A file object (or an Array of them)
|
||||
* @arg {Buffer} content.file[].file A buffer containing file data
|
||||
* @arg {String} content.file[].name What to name the file
|
||||
* @arg {Number} [content.flags] A number representing the flags to apply to the message. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for flags reference
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
edit(content) {
|
||||
if(this.flags & MessageFlags.EPHEMERAL) {
|
||||
throw new Error("Ephemeral messages cannot be edited via this method");
|
||||
}
|
||||
return this._client.editMessage.call(this._client, this.channel.id, this.id, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit the message as a webhook
|
||||
* @arg {String} token The token of the webhook
|
||||
* @arg {Object} options Webhook message edit options
|
||||
* @arg {Object} [options.allowedMentions] A list of mentions to allow (overrides default)
|
||||
* @arg {Boolean} [options.allowedMentions.everyone] Whether or not to allow @everyone/@here.
|
||||
* @arg {Boolean} [options.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to.
|
||||
* @arg {Boolean | Array<String>} [options.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
|
||||
* @arg {Boolean | Array<String>} [options.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
|
||||
* @arg {Array<Object>} [options.components] An array of component objects
|
||||
* @arg {String} [options.components[].custom_id] The ID of the component (type 2 style 0-4 and type 3 only)
|
||||
* @arg {Boolean} [options.components[].disabled] Whether the component is disabled (type 2 only)
|
||||
* @arg {Object} [options.components[].emoji] The emoji to be displayed in the component (type 2)
|
||||
* @arg {String} [options.components[].label] The label to be displayed in the component (type 2)
|
||||
* @arg {Number} [options.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
||||
* @arg {Number} [options.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
||||
* @arg {Array<Object>} [options.components[].options] The options for this component (type 3 only)
|
||||
* @arg {Boolean} [options.components[].options[].default] Whether this option should be the default value selected
|
||||
* @arg {String} [options.components[].options[].description] The description for this option
|
||||
* @arg {Object} [options.components[].options[].emoji] The emoji to be displayed in this option
|
||||
* @arg {String} options.components[].options[].label The label for this option
|
||||
* @arg {Number | String} options.components[].options[].value The value for this option
|
||||
* @arg {String} [options.components[].placeholder] The placeholder text for the component when no option is selected (type 3 only)
|
||||
* @arg {Number} [options.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
|
||||
* @arg {Number} options.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
|
||||
* @arg {String} [options.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
||||
* @arg {String} [options.content] A content string
|
||||
* @arg {Object} [options.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Array<Object>} [options.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Object | Array<Object>} [options.file] A file object (or an Array of them)
|
||||
* @arg {Buffer} options.file.file A buffer containing file data
|
||||
* @arg {String} options.file.name What to name the file
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
editWebhook(token, options) {
|
||||
if(!this.webhookID) {
|
||||
throw new Error("Message is not a webhook");
|
||||
}
|
||||
return this._client.editWebhookMessage.call(this._client, this.webhookID, token, this.id, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of users who reacted with a specific reaction
|
||||
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
||||
* @arg {Object} [options] Options for the request. If this is a number, it is treated as `options.limit` ([DEPRECATED] behavior)
|
||||
* @arg {Number} [options.limit=100] The maximum number of users to get
|
||||
* @arg {String} [options.after] Get users after this user ID
|
||||
* @arg {String} [before] [DEPRECATED] Get users before this user ID. Discord no longer supports this parameter
|
||||
* @arg {String} [after] [DEPRECATED] Get users after this user ID
|
||||
* @returns {Promise<Array<User>>}
|
||||
*/
|
||||
getReaction(reaction, options, before, after) {
|
||||
if(this.flags & MessageFlags.EPHEMERAL) {
|
||||
throw new Error("Ephemeral messages cannot have reactions");
|
||||
}
|
||||
return this._client.getMessageReaction.call(this._client, this.channel.id, this.id, reaction, options, before, after);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pin the message
|
||||
* @returns {Promise}
|
||||
*/
|
||||
pin() {
|
||||
if(this.flags & MessageFlags.EPHEMERAL) {
|
||||
throw new Error("Ephemeral messages cannot be pinned");
|
||||
}
|
||||
return this._client.pinMessage.call(this._client, this.channel.id, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a reaction from a message
|
||||
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
||||
* @arg {String} [userID="@me"] The ID of the user to remove the reaction for.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
removeReaction(reaction, userID) {
|
||||
if(this.flags & MessageFlags.EPHEMERAL) {
|
||||
throw new Error("Ephemeral messages cannot have reactions");
|
||||
}
|
||||
return this._client.removeMessageReaction.call(this._client, this.channel.id, this.id, reaction, userID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all reactions from a message for a single emoji
|
||||
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
||||
* @returns {Promise}
|
||||
*/
|
||||
removeReactionEmoji(reaction) {
|
||||
if(this.flags & MessageFlags.EPHEMERAL) {
|
||||
throw new Error("Ephemeral messages cannot have reactions");
|
||||
}
|
||||
return this._client.removeMessageReactionEmoji.call(this._client, this.channel.id, this.id, reaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all reactions from a message
|
||||
* @returns {Promise}
|
||||
*/
|
||||
removeReactions() {
|
||||
if(this.flags & MessageFlags.EPHEMERAL) {
|
||||
throw new Error("Ephemeral messages cannot have reactions");
|
||||
}
|
||||
return this._client.removeMessageReactions.call(this._client, this.channel.id, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpin the message
|
||||
* @returns {Promise}
|
||||
*/
|
||||
unpin() {
|
||||
if(this.flags & MessageFlags.EPHEMERAL) {
|
||||
throw new Error("Ephemeral messages cannot be pinned");
|
||||
}
|
||||
return this._client.unpinMessage.call(this._client, this.channel.id, this.id);
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"activity",
|
||||
"application",
|
||||
"attachments",
|
||||
"author",
|
||||
"content",
|
||||
"editedTimestamp",
|
||||
"embeds",
|
||||
"flags",
|
||||
"guildID",
|
||||
"hit",
|
||||
"member",
|
||||
"mentionEveryone",
|
||||
"mentions",
|
||||
"messageReference",
|
||||
"pinned",
|
||||
"reactions",
|
||||
"referencedMesssage",
|
||||
"roleMentions",
|
||||
"stickers",
|
||||
"stickerItems",
|
||||
"timestamp",
|
||||
"tts",
|
||||
"type",
|
||||
"webhookID",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Message;
|
35
node_modules/eris/lib/structures/NewsChannel.js
generated
vendored
Normal file
35
node_modules/eris/lib/structures/NewsChannel.js
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
|
||||
const TextChannel = require("./TextChannel");
|
||||
|
||||
/**
|
||||
* Represents a guild news channel. See TextChannel for more properties and methods.
|
||||
* @extends TextChannel
|
||||
*/
|
||||
class NewsChannel extends TextChannel {
|
||||
constructor(data, guild, messageLimit) {
|
||||
super(data, guild, messageLimit);
|
||||
this.rateLimitPerUser = 0;
|
||||
this.update(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Crosspost (publish) a message to subscribed channels
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
crosspostMessage(messageID) {
|
||||
return this.client.crosspostMessage.call(this.client, this.id, messageID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Follow this channel in another channel. This creates a webhook in the target channel
|
||||
* @arg {String} webhookChannelID The ID of the target channel
|
||||
* @returns {Object} An object containing this channel's ID and the new webhook's ID
|
||||
*/
|
||||
follow(webhookChannelID) {
|
||||
return this.client.followChannel.call(this.client, this.id, webhookChannelID);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = NewsChannel;
|
15
node_modules/eris/lib/structures/NewsThreadChannel.js
generated
vendored
Normal file
15
node_modules/eris/lib/structures/NewsThreadChannel.js
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
const ThreadChannel = require("./ThreadChannel");
|
||||
|
||||
/**
|
||||
* Represents a news thread channel. See ThreadChannel for extra properties.
|
||||
* @extends ThreadChannel
|
||||
*/
|
||||
class NewsThreadChannel extends ThreadChannel {
|
||||
constructor(data, client, messageLimit) {
|
||||
super(data, client, messageLimit);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = NewsThreadChannel;
|
71
node_modules/eris/lib/structures/Permission.js
generated
vendored
Normal file
71
node_modules/eris/lib/structures/Permission.js
generated
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
"use strict";
|
||||
|
||||
const Base = require("./Base");
|
||||
const {Permissions} = require("../Constants");
|
||||
|
||||
/**
|
||||
* Represents a calculated permissions number
|
||||
* @prop {BigInt} allow The allowed permissions number
|
||||
* @prop {BigInt} deny The denied permissions number
|
||||
* @prop {Object} json A JSON representation of the permissions number.
|
||||
* If a permission key isn't there, it is not set by this permission.
|
||||
* If a permission key is false, it is denied by the permission.
|
||||
* If a permission key is true, it is allowed by the permission.
|
||||
* i.e.:
|
||||
* {
|
||||
* "readMessages": true,
|
||||
* "sendMessages": true,
|
||||
* "manageMessages": false
|
||||
* }
|
||||
* In the above example, readMessages and sendMessages are allowed permissions, and manageMessages is denied. Everything else is not explicitly set.
|
||||
* [A full list of permission nodes can be found on the docs reference page](/Eris/docs/reference)
|
||||
*/
|
||||
class Permission extends Base {
|
||||
constructor(allow, deny = 0) {
|
||||
super();
|
||||
this.allow = BigInt(allow);
|
||||
this.deny = BigInt(deny);
|
||||
}
|
||||
|
||||
get json() {
|
||||
if(!this._json) {
|
||||
this._json = {};
|
||||
for(const perm of Object.keys(Permissions)) {
|
||||
if(!perm.startsWith("all")) {
|
||||
if(this.allow & Permissions[perm]) {
|
||||
this._json[perm] = true;
|
||||
} else if(this.deny & Permissions[perm]) {
|
||||
this._json[perm] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return this._json;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this permission allows a specific permission
|
||||
* @arg {String | BigInt} permission The name of the permission, or bit of permissions. [A full list of permission nodes can be found on the docs reference page](/Eris/docs/reference). Pass a BigInt if you want to check multiple permissions.
|
||||
* @returns {Boolean} Whether the permission allows the specified permission
|
||||
*/
|
||||
has(permission) {
|
||||
if(typeof permission === "bigint") {
|
||||
return (this.allow & permission) === permission;
|
||||
}
|
||||
return !!(this.allow & Permissions[permission]);
|
||||
}
|
||||
|
||||
toString() {
|
||||
return `[${this.constructor.name} +${this.allow} -${this.deny}]`;
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"allow",
|
||||
"deny",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Permission;
|
26
node_modules/eris/lib/structures/PermissionOverwrite.js
generated
vendored
Normal file
26
node_modules/eris/lib/structures/PermissionOverwrite.js
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
|
||||
const Permission = require("./Permission");
|
||||
|
||||
/**
|
||||
* Represents a permission overwrite
|
||||
* @extends Permission
|
||||
* @prop {String} id The ID of the overwrite
|
||||
* @prop {Number} type The type of the overwrite, either 1 for "member" or 0 for "role"
|
||||
*/
|
||||
class PermissionOverwrite extends Permission {
|
||||
constructor(data) {
|
||||
super(data.allow, data.deny);
|
||||
this.id = data.id;
|
||||
this.type = data.type;
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"type",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = PermissionOverwrite;
|
40
node_modules/eris/lib/structures/PingInteraction.js
generated
vendored
Normal file
40
node_modules/eris/lib/structures/PingInteraction.js
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
|
||||
const Interaction = require("./Interaction");
|
||||
const {InteractionResponseTypes} = require("../Constants");
|
||||
|
||||
/**
|
||||
* Represents a ping interaction. See Interaction for more properties.
|
||||
* @extends Interaction
|
||||
*/
|
||||
class PingInteraction extends Interaction {
|
||||
constructor(info, client) {
|
||||
super(info, client);
|
||||
}
|
||||
|
||||
/**
|
||||
* Acknowledges the ping interaction with a pong response.
|
||||
* Note: You can **not** use more than 1 initial interaction response per interaction.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async acknowledge() {
|
||||
return this.pong();
|
||||
}
|
||||
|
||||
/**
|
||||
* Acknowledges the ping interaction with a pong response.
|
||||
* Note: You can **not** use more than 1 initial interaction response per interaction.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async pong() {
|
||||
if(this.acknowledged === true) {
|
||||
throw new Error("You have already acknowledged this interaction.");
|
||||
}
|
||||
return this._client.createInteractionResponse.call(this._client, this.id, this.token, {
|
||||
type: InteractionResponseTypes.PONG
|
||||
}).then(() => this.update());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = PingInteraction;
|
269
node_modules/eris/lib/structures/PrivateChannel.js
generated
vendored
Normal file
269
node_modules/eris/lib/structures/PrivateChannel.js
generated
vendored
Normal file
@ -0,0 +1,269 @@
|
||||
"use strict";
|
||||
|
||||
const Channel = require("./Channel");
|
||||
const Collection = require("../util/Collection");
|
||||
const Endpoints = require("../rest/Endpoints");
|
||||
const Message = require("./Message");
|
||||
const {GatewayOPCodes, ChannelTypes} = require("../Constants");
|
||||
const User = require("./User");
|
||||
|
||||
/**
|
||||
* Represents a private channel. See Channel for more properties and methods.
|
||||
* @extends Channel
|
||||
* @prop {String} lastMessageID The ID of the last message in this channel
|
||||
* @prop {Collection<Message>} messages Collection of Messages in this channel
|
||||
* @prop {User} recipient The recipient in this private channel (private channels only)
|
||||
*/
|
||||
class PrivateChannel extends Channel {
|
||||
constructor(data, client) {
|
||||
super(data, client);
|
||||
this.lastMessageID = data.last_message_id;
|
||||
this.rateLimitPerUser = data.rate_limit_per_user;
|
||||
this.call = this.lastCall = null;
|
||||
if(this.type === ChannelTypes.DM || this.type === undefined) {
|
||||
this.recipient = new User(data.recipients[0], client);
|
||||
}
|
||||
this.messages = new Collection(Message, client.options.messageLimit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a reaction to a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
||||
* @arg {String} [userID="@me"] The ID of the user to react as. Passing this parameter is deprecated and will not be supported in future versions.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
addMessageReaction(messageID, reaction, userID) {
|
||||
return this.client.addMessageReaction.call(this.client, this.id, messageID, reaction, userID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a message in a text channel
|
||||
* @arg {String | Object} content A string or object. If an object is passed:
|
||||
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
||||
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
|
||||
* @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to.
|
||||
* @arg {Array<Object>} [content.components] An array of component objects
|
||||
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 0-4 and type 3 only)
|
||||
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3 only)
|
||||
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
||||
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
||||
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
||||
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
||||
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
||||
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
||||
* @arg {String} [content.components[].options[].description] The description for this option
|
||||
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
||||
* @arg {String} content.components[].options[].label The label for this option
|
||||
* @arg {Number | String} content.components[].options[].value The value for this option
|
||||
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3 only)
|
||||
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
|
||||
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
|
||||
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
||||
* @arg {String} [content.content] A content string
|
||||
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Object} [content.messageReference] The message reference, used when replying to messages
|
||||
* @arg {String} [content.messageReference.channelID] The channel ID of the referenced message
|
||||
* @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message
|
||||
* @arg {String} [content.messageReference.guildID] The guild ID of the referenced message
|
||||
* @arg {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message
|
||||
* @arg {String} [content.messageReferenceID] [DEPRECATED] The ID of the message should be replied to. Use `messageReference` instead
|
||||
* @arg {Array<String>} [content.stickerIDs] An array of IDs corresponding to stickers to send
|
||||
* @arg {Boolean} [content.tts] Set the message TTS flag
|
||||
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
||||
* @arg {Buffer} file.file A buffer containing file data
|
||||
* @arg {String} file.name What to name the file
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
createMessage(content, file) {
|
||||
return this.client.createMessage.call(this.client, this.id, content, file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise}
|
||||
*/
|
||||
deleteMessage(messageID, reason) {
|
||||
return this.client.deleteMessage.call(this.client, this.id, messageID, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @arg {String | Array | Object} content A string, array of strings, or object. If an object is passed:
|
||||
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
||||
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
|
||||
* @arg {Array<Object>} [content.components] An array of component objects
|
||||
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 0-4 and type 3 only)
|
||||
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3 only)
|
||||
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
||||
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
||||
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
||||
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
||||
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
||||
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
||||
* @arg {String} [content.components[].options[].description] The description for this option
|
||||
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
||||
* @arg {String} content.components[].options[].label The label for this option
|
||||
* @arg {Number | String} content.components[].options[].value The value for this option
|
||||
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3 only)
|
||||
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
|
||||
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
|
||||
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
||||
* @arg {String} [content.content] A content string
|
||||
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Object | Array<Object>} [content.file] A file object (or an Array of them)
|
||||
* @arg {Buffer} content.file[].file A buffer containing file data
|
||||
* @arg {String} content.file[].name What to name the file
|
||||
* @arg {Number} [content.flags] A number representing the flags to apply to the message. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for flags reference
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
editMessage(messageID, content) {
|
||||
return this.client.editMessage.call(this.client, this.id, messageID, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a previous message in a text channel
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
getMessage(messageID) {
|
||||
return this.client.getMessage.call(this.client, this.id, messageID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of users who reacted with a specific reaction
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
||||
* @arg {Object} [options] Options for the request. If this is a number, it is treated as `options.limit` ([DEPRECATED] behavior)
|
||||
* @arg {Number} [options.limit=100] The maximum number of users to get
|
||||
* @arg {String} [options.after] Get users after this user ID
|
||||
* @arg {String} [before] [DEPRECATED] Get users before this user ID. Discord no longer supports this parameter
|
||||
* @arg {String} [after] [DEPRECATED] Get users after this user ID
|
||||
* @returns {Promise<Array<User>>}
|
||||
*/
|
||||
getMessageReaction(messageID, reaction, options, before, after) {
|
||||
return this.client.getMessageReaction.call(this.client, this.id, messageID, reaction, options, before, after);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a previous message in a text channel
|
||||
* @arg {Object} [options] Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit`
|
||||
* @arg {String} [options.after] Get messages after this message ID
|
||||
* @arg {String} [options.around] Get messages around this message ID (does not work with limit > 100)
|
||||
* @arg {String} [options.before] Get messages before this message ID
|
||||
* @arg {Number} [options.limit=50] The max number of messages to get
|
||||
* @arg {String} [before] [DEPRECATED] Get messages before this message ID
|
||||
* @arg {String} [after] [DEPRECATED] Get messages after this message ID
|
||||
* @arg {String} [around] [DEPRECATED] Get messages around this message ID (does not work with limit > 100)
|
||||
* @returns {Promise<Array<Message>>}
|
||||
*/
|
||||
getMessages(options, before, after, around) {
|
||||
return this.client.getMessages.call(this.client, this.id, options, before, after, around);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the pins in a text channel
|
||||
* @returns {Promise<Array<Message>>}
|
||||
*/
|
||||
getPins() {
|
||||
return this.client.getPins.call(this.client, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Leave the channel
|
||||
* @returns {Promise}
|
||||
*/
|
||||
leave() {
|
||||
return this.client.deleteChannel.call(this.client, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pin a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @returns {Promise}
|
||||
*/
|
||||
pinMessage(messageID) {
|
||||
return this.client.pinMessage.call(this.client, this.id, messageID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a reaction from a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
||||
* @arg {String} [userID="@me"] The ID of the user to remove the reaction for. Passing this parameter is deprecated and will not be supported in future versions.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
removeMessageReaction(messageID, reaction, userID) {
|
||||
if(userID !== undefined) {
|
||||
this.emit("warn", "[DEPRECATED] removeMessageReaction() was called on a PrivateChannel with a `userID` argument");
|
||||
}
|
||||
return this.client.removeMessageReaction.call(this.client, this.id, messageID, reaction, userID);
|
||||
}
|
||||
|
||||
/**
|
||||
* [USER ACCOUNT] Ring fellow group channel recipient(s)
|
||||
* @arg {Array<String>} recipients The IDs of the recipients to ring
|
||||
*/
|
||||
ring(recipients) {
|
||||
this.client.requestHandler.request("POST", Endpoints.CHANNEL_CALL_RING(this.id), true, {
|
||||
recipients
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Send typing status in a text channel
|
||||
* @returns {Promise}
|
||||
*/
|
||||
sendTyping() {
|
||||
return this.client.sendChannelTyping.call(this.client, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the channel has an existing call
|
||||
*/
|
||||
syncCall() {
|
||||
this.client.shards.values().next().value.sendWS(GatewayOPCodes.SYNC_CALL, {
|
||||
channel_id: this.id
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpin a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @returns {Promise}
|
||||
*/
|
||||
unpinMessage(messageID) {
|
||||
return this.client.unpinMessage.call(this.client, this.id, messageID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Un-send a message. You're welcome Programmix
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @returns {Promise}
|
||||
*/
|
||||
unsendMessage(messageID) {
|
||||
return this.client.deleteMessage.call(this.client, this.id, messageID);
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"call",
|
||||
"lastCall",
|
||||
"lastMessageID",
|
||||
"messages",
|
||||
"recipient",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = PrivateChannel;
|
34
node_modules/eris/lib/structures/PrivateThreadChannel.js
generated
vendored
Normal file
34
node_modules/eris/lib/structures/PrivateThreadChannel.js
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
|
||||
const ThreadChannel = require("./ThreadChannel");
|
||||
|
||||
/**
|
||||
* Represents a private thread channel. See ThreadChannel for extra properties.
|
||||
* @extends ThreadChannel
|
||||
* @prop {Object} threadMetadata Metadata for the thread
|
||||
* @prop {Number} threadMetadata.archiveTimestamp Timestamp when the thread's archive status was last changed, used for calculating recent activity
|
||||
* @prop {Boolean} threadMetadata.archived Whether the thread is archived
|
||||
* @prop {Number} threadMetadata.autoArchiveDuration Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080
|
||||
* @prop {Boolean} threadMetadata.invitable Whether non-moderators can add other non-moderators to the thread
|
||||
* @prop {Boolean} threadMetadata.locked Whether the thread is locked
|
||||
*/
|
||||
class PrivateThreadChannel extends ThreadChannel {
|
||||
constructor(data, client, messageLimit) {
|
||||
super(data, client, messageLimit);
|
||||
this.update(data);
|
||||
}
|
||||
|
||||
update(data) {
|
||||
if(data.thread_metadata !== undefined) {
|
||||
this.threadMetadata = {
|
||||
archiveTimestamp: Date.parse(data.thread_metadata.archive_timestamp),
|
||||
archived: data.thread_metadata.archived,
|
||||
autoArchiveDuration: data.thread_metadata.auto_archive_duration,
|
||||
invitable: data.thread_metadata.invitable,
|
||||
locked: data.thread_metadata.locked
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = PrivateThreadChannel;
|
15
node_modules/eris/lib/structures/PublicThreadChannel.js
generated
vendored
Normal file
15
node_modules/eris/lib/structures/PublicThreadChannel.js
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
const ThreadChannel = require("./ThreadChannel");
|
||||
|
||||
/**
|
||||
* Represents a public thread channel. See ThreadChannel for extra properties.
|
||||
* @extends ThreadChannel
|
||||
*/
|
||||
class PublicThreadChannel extends ThreadChannel {
|
||||
constructor(data, client, messageLimit) {
|
||||
super(data, client, messageLimit);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = PublicThreadChannel;
|
48
node_modules/eris/lib/structures/Relationship.js
generated
vendored
Normal file
48
node_modules/eris/lib/structures/Relationship.js
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
|
||||
const Base = require("./Base");
|
||||
|
||||
/**
|
||||
* [USER ACCOUNT] Represents a Relationship
|
||||
* @prop {User} user The other user in the relationship
|
||||
* @prop {Number} type The type of relationship. 1 is friend, 2 is block, 3 is incoming request, 4 is outgoing request
|
||||
* @prop {String} status The other user's status. Either "online", "idle", or "offline"
|
||||
* @prop {Object?} game The active game the other user is playing
|
||||
* @prop {String} game.name The name of the active game
|
||||
* @prop {Number} game.type The type of the active game (0 is default, 1 is Twitch, 2 is YouTube)
|
||||
* @prop {String?} game.url The url of the active game
|
||||
*/
|
||||
class Relationship extends Base {
|
||||
constructor(data, client) {
|
||||
super(data.id);
|
||||
this.user = client.users.add(data.user, client);
|
||||
this.type = 0;
|
||||
this.status = "offline";
|
||||
this.activities = null;
|
||||
this.update(data);
|
||||
}
|
||||
|
||||
update(data) {
|
||||
if(data.type !== undefined) {
|
||||
this.type = data.type;
|
||||
}
|
||||
if(data.status !== undefined) {
|
||||
this.status = data.status;
|
||||
}
|
||||
if(data.activities !== undefined) {
|
||||
this.activities = data.activities;
|
||||
}
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"activities",
|
||||
"status",
|
||||
"type",
|
||||
"user",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Relationship;
|
136
node_modules/eris/lib/structures/Role.js
generated
vendored
Normal file
136
node_modules/eris/lib/structures/Role.js
generated
vendored
Normal file
@ -0,0 +1,136 @@
|
||||
"use strict";
|
||||
|
||||
const Base = require("./Base");
|
||||
const Endpoints = require("../rest/Endpoints");
|
||||
const Permission = require("./Permission");
|
||||
|
||||
/**
|
||||
* Represents a role
|
||||
* @prop {Number} color The hex color of the role in base 10
|
||||
* @prop {Number} createdAt Timestamp of the role's creation
|
||||
* @prop {Boolean} hoist Whether users with this role are hoisted in the user list or not
|
||||
* @prop {String?} icon The hash of the role's icon, or null if no icon
|
||||
* @prop {String?} iconURL The URL of the role's icon
|
||||
* @prop {String} id The ID of the role
|
||||
* @prop {Object} json Generates a JSON representation of the role permissions
|
||||
* @prop {Guild} guild The guild that owns the role
|
||||
* @prop {Boolean} managed Whether a guild integration manages this role or not
|
||||
* @prop {String} mention A string that mentions the role
|
||||
* @prop {Boolean} mentionable Whether the role is mentionable or not
|
||||
* @prop {String} name The name of the role
|
||||
* @prop {Permission} permissions The permissions representation of the role
|
||||
* @prop {Number} position The position of the role
|
||||
* @prop {Object?} tags The tags of the role
|
||||
* @prop {String?} tags.bot_id The ID of the bot associated with the role
|
||||
* @prop {String?} tags.integration_id The ID of the integration associated with the role
|
||||
* @prop {Boolean?} tags.premium_subscriber Whether the role is the guild's premium subscriber role
|
||||
* @prop {String?} unicodeEmoji Unicode emoji for the role
|
||||
*/
|
||||
class Role extends Base {
|
||||
constructor(data, guild) {
|
||||
super(data.id);
|
||||
this.guild = guild;
|
||||
this.update(data);
|
||||
}
|
||||
|
||||
update(data) {
|
||||
if(data.name !== undefined) {
|
||||
this.name = data.name;
|
||||
}
|
||||
if(data.mentionable !== undefined) {
|
||||
this.mentionable = data.mentionable;
|
||||
}
|
||||
if(data.managed !== undefined) {
|
||||
this.managed = data.managed;
|
||||
}
|
||||
if(data.hoist !== undefined) {
|
||||
this.hoist = data.hoist;
|
||||
}
|
||||
if(data.color !== undefined) {
|
||||
this.color = data.color;
|
||||
}
|
||||
if(data.position !== undefined) {
|
||||
this.position = data.position;
|
||||
}
|
||||
if(data.permissions !== undefined) {
|
||||
this.permissions = new Permission(data.permissions);
|
||||
}
|
||||
if(data.tags !== undefined) {
|
||||
this.tags = data.tags;
|
||||
if(this.tags.premium_subscriber === null) {
|
||||
this.tags.premium_subscriber = true;
|
||||
}
|
||||
}
|
||||
if(data.icon !== undefined) {
|
||||
this.icon = data.icon;
|
||||
}
|
||||
if(data.unicode_emoji !== undefined) {
|
||||
this.unicodeEmoji = data.unicode_emoji;
|
||||
}
|
||||
}
|
||||
|
||||
get iconURL() {
|
||||
return this.icon ? this.guild.shard.client._formatImage(Endpoints.ROLE_ICON(this.id, this.icon)) : null;
|
||||
}
|
||||
|
||||
get json() {
|
||||
return this.permissions.json;
|
||||
}
|
||||
|
||||
get mention() {
|
||||
return `<@&${this.id}>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the role
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise}
|
||||
*/
|
||||
delete(reason) {
|
||||
return this.guild.shard.client.deleteRole.call(this.guild.shard.client, this.guild.id, this.id, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit the guild role
|
||||
* @arg {Object} options The properties to edit
|
||||
* @arg {Number} [options.color] The hex color of the role, in number form (ex: 0x3da5b3 or 4040115)
|
||||
* @arg {Boolean} [options.hoist] Whether to hoist the role in the user list or not
|
||||
* @arg {String} [options.icon] The role icon as a base64 data URI
|
||||
* @arg {Boolean} [options.mentionable] Whether the role is mentionable or not
|
||||
* @arg {String} [options.name] The name of the role
|
||||
* @arg {BigInt | Number} [options.permissions] The role permissions number
|
||||
* @arg {String?} [options.unicodeEmoji] The role's unicode emoji
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise<Role>}
|
||||
*/
|
||||
edit(options, reason) {
|
||||
return this.guild.shard.client.editRole.call(this.guild.shard.client, this.guild.id, this.id, options, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit the role's position. Note that role position numbers are highest on top and lowest at the bottom.
|
||||
* @arg {Number} position The new position of the role
|
||||
* @returns {Promise}
|
||||
*/
|
||||
editPosition(position) {
|
||||
return this.guild.shard.client.editRolePosition.call(this.guild.shard.client, this.guild.id, this.id, position);
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"color",
|
||||
"hoist",
|
||||
"icon",
|
||||
"managed",
|
||||
"mentionable",
|
||||
"name",
|
||||
"permissions",
|
||||
"position",
|
||||
"tags",
|
||||
"unicodeEmoji",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Role;
|
64
node_modules/eris/lib/structures/StageChannel.js
generated
vendored
Normal file
64
node_modules/eris/lib/structures/StageChannel.js
generated
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
|
||||
const VoiceChannel = require("./VoiceChannel");
|
||||
|
||||
/**
|
||||
* Represents a guild stage channel. See VoiceChannel for more properties and methods.
|
||||
* @extends VoiceChannel
|
||||
* @prop {String?} topic The topic of the channel
|
||||
*/
|
||||
class StageChannel extends VoiceChannel {
|
||||
update(data) {
|
||||
super.update(data);
|
||||
if(data.topic !== undefined) {
|
||||
this.topic = data.topic;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a stage instance
|
||||
* @arg {Object} options The stage instance options
|
||||
* @arg {Number} [options.privacyLevel] The privacy level of the stage instance. 1 is public, 2 is guild only
|
||||
* @arg {String} options.topic The stage instance topic
|
||||
* @returns {Promise<StageInstance>}
|
||||
*/
|
||||
createInstance(options) {
|
||||
return this.client.createStageInstance.call(this.client, this.id, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the stage instance for this channel
|
||||
* @returns {Promise}
|
||||
*/
|
||||
deleteInstance() {
|
||||
return this.client.deleteStageInstance.call(this.client, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the stage instance for this channel
|
||||
* @arg {Object} options The properties to edit
|
||||
* @arg {Number} [options.privacyLevel] The privacy level of the stage instance. 1 is public, 2 is guild only
|
||||
* @arg {String} [options.topic] The stage instance topic
|
||||
* @returns {Promise<StageInstance>}
|
||||
*/
|
||||
editInstance(options) {
|
||||
return this.client.editStageInstance.call(this.client, this.id, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the stage instance for this channel
|
||||
* @returns {Promise<StageInstance>}
|
||||
*/
|
||||
getInstance() {
|
||||
return this.client.getStageInstance.call(this.client, this.id);
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"topic",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = StageChannel;
|
55
node_modules/eris/lib/structures/StageInstance.js
generated
vendored
Normal file
55
node_modules/eris/lib/structures/StageInstance.js
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
|
||||
const Base = require("./Base");
|
||||
|
||||
/**
|
||||
* Represents a stage instance
|
||||
* @prop {StageChannel} channel The associated stage channel
|
||||
* @prop {Boolean} discoverableDisabled Whether or not stage discovery is disabled
|
||||
* @prop {Guild} guild The guild of the associated stage channel
|
||||
* @prop {String} id The ID of the stage instance
|
||||
* @prop {Number} privacyLevel The privacy level of the stage instance. 1 is public, 2 is guild only
|
||||
* @prop {String} topic The stage instance topic
|
||||
*/
|
||||
class StageInstance extends Base {
|
||||
constructor(data, client) {
|
||||
super(data.id);
|
||||
this._client = client;
|
||||
this.channel = client.getChannel(data.channel_id) || {id: data.channel_id};
|
||||
this.guild = client.guilds.get(data.guild_id) || {id: data.guild_id};
|
||||
this.update(data);
|
||||
}
|
||||
|
||||
update(data) {
|
||||
if(data.discoverable_disabled !== undefined) {
|
||||
this.discoverableDisabled = data.discoverable_disabled;
|
||||
}
|
||||
if(data.privacy_level !== undefined) {
|
||||
this.privacyLevel = data.privacy_level;
|
||||
}
|
||||
if(data.topic !== undefined) {
|
||||
this.topic = data.topic;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete this stage instance
|
||||
* @returns {Promise}
|
||||
*/
|
||||
delete() {
|
||||
return this._client.deleteStageInstance.call(this._client, this.channel.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update this stage instance
|
||||
* @arg {Object} options The properties to edit
|
||||
* @arg {Number} [options.privacyLevel] The privacy level of the stage instance. 1 is public, 2 is guild only
|
||||
* @arg {String} [options.topic] The stage instance topic
|
||||
* @returns {Promise<StageInstance>}
|
||||
*/
|
||||
edit(options) {
|
||||
return this._client.editStageInstance.call(this._client, this.channel.id, options);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = StageInstance;
|
12
node_modules/eris/lib/structures/StoreChannel.js
generated
vendored
Normal file
12
node_modules/eris/lib/structures/StoreChannel.js
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
const GuildChannel = require("./GuildChannel");
|
||||
|
||||
/**
|
||||
* Represents a store channel. See GuildChannel for more properties and methods. Bots cannot read or send messages in a store channel.
|
||||
* @extends GuildChannel
|
||||
*/
|
||||
class StoreChannel extends GuildChannel {
|
||||
}
|
||||
|
||||
module.exports = StoreChannel;
|
395
node_modules/eris/lib/structures/TextChannel.js
generated
vendored
Normal file
395
node_modules/eris/lib/structures/TextChannel.js
generated
vendored
Normal file
@ -0,0 +1,395 @@
|
||||
"use strict";
|
||||
|
||||
const Collection = require("../util/Collection");
|
||||
const GuildChannel = require("./GuildChannel");
|
||||
const Message = require("./Message");
|
||||
|
||||
/**
|
||||
* Represents a guild text channel. See GuildChannel for more properties and methods.
|
||||
* @extends GuildChannel
|
||||
* @prop {Number} defaultAutoArchiveDuration The default duration of newly created threads in minutes to automatically archive the thread after inactivity (60, 1440, 4320, 10080)
|
||||
* @prop {String} lastMessageID The ID of the last message in this channel
|
||||
* @prop {Number} lastPinTimestamp The timestamp of the last pinned message
|
||||
* @prop {Collection<Message>} messages Collection of Messages in this channel
|
||||
* @prop {Number} rateLimitPerUser The ratelimit of the channel, in seconds. 0 means no ratelimit is enabled
|
||||
* @prop {String?} topic The topic of the channel
|
||||
*/
|
||||
class TextChannel extends GuildChannel {
|
||||
constructor(data, client, messageLimit) {
|
||||
super(data, client);
|
||||
this.messages = new Collection(Message, messageLimit == null ? client.options.messageLimit : messageLimit);
|
||||
this.lastMessageID = data.last_message_id || null;
|
||||
this.rateLimitPerUser = data.rate_limit_per_user == null ? null : data.rate_limit_per_user;
|
||||
this.lastPinTimestamp = data.last_pin_timestamp ? Date.parse(data.last_pin_timestamp) : null;
|
||||
this.update(data);
|
||||
}
|
||||
|
||||
update(data) {
|
||||
super.update(data);
|
||||
if(data.rate_limit_per_user !== undefined) {
|
||||
this.rateLimitPerUser = data.rate_limit_per_user;
|
||||
}
|
||||
if(data.topic !== undefined) {
|
||||
this.topic = data.topic;
|
||||
}
|
||||
if(data.default_auto_archive_duration !== undefined) {
|
||||
this.defaultAutoArchiveDuration = data.default_auto_archive_duration;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a reaction to a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
||||
* @arg {String} [userID="@me"] The ID of the user to react as. Passing this parameter is deprecated and will not be supported in future versions.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
addMessageReaction(messageID, reaction, userID) {
|
||||
return this.client.addMessageReaction.call(this.client, this.id, messageID, reaction, userID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an invite for the channel
|
||||
* @arg {Object} [options] Invite generation options
|
||||
* @arg {Number} [options.maxAge] How long the invite should last in seconds
|
||||
* @arg {Number} [options.maxUses] How many uses the invite should last for
|
||||
* @arg {Boolean} [options.temporary] Whether the invite grants temporary membership or not
|
||||
* @arg {Boolean} [options.unique] Whether the invite is unique or not
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise<Invite>}
|
||||
*/
|
||||
createInvite(options, reason) {
|
||||
return this.client.createChannelInvite.call(this.client, this.id, options, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a message in the channel
|
||||
* @arg {String | Object} content A string or object. If an object is passed:
|
||||
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
||||
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
|
||||
* @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to.
|
||||
* @arg {Array<Object>} [content.components] An array of component objects
|
||||
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 0-4 and type 3 only)
|
||||
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3 only)
|
||||
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
||||
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
||||
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
||||
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
||||
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
||||
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
||||
* @arg {String} [content.components[].options[].description] The description for this option
|
||||
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
||||
* @arg {String} content.components[].options[].label The label for this option
|
||||
* @arg {Number | String} content.components[].options[].value The value for this option
|
||||
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3 only)
|
||||
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
|
||||
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
|
||||
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
||||
* @arg {String} [content.content] A content string
|
||||
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Object} [content.messageReference] The message reference, used when replying to messages
|
||||
* @arg {String} [content.messageReference.channelID] The channel ID of the referenced message
|
||||
* @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message
|
||||
* @arg {String} [content.messageReference.guildID] The guild ID of the referenced message
|
||||
* @arg {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message
|
||||
* @arg {String} [content.messageReferenceID] [DEPRECATED] The ID of the message should be replied to. Use `messageReference` instead
|
||||
* @arg {Array<String>} [content.stickerIDs] An array of IDs corresponding to stickers to send
|
||||
* @arg {Boolean} [content.tts] Set the message TTS flag
|
||||
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
||||
* @arg {Buffer} file.file A buffer containing file data
|
||||
* @arg {String} file.name What to name the file
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
createMessage(content, file) {
|
||||
return this.client.createMessage.call(this.client, this.id, content, file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a thread with an existing message
|
||||
* @arg {String} messageID The ID of the message to create the thread from
|
||||
* @arg {Object} options The thread options
|
||||
* @arg {Number} options.autoArchiveDuration Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080
|
||||
* @arg {String} options.name The thread channel name
|
||||
* @returns {Promise<NewsThreadChannel | PublicThreadChannel>}
|
||||
*/
|
||||
createThreadWithMessage(messageID, options) {
|
||||
return this.client.createThreadWithMessage.call(this.client, this.id, messageID, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a thread without an existing message
|
||||
* @arg {Object} options The thread options
|
||||
* @arg {Number} options.autoArchiveDuration Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080
|
||||
* @arg {boolean} [options.invitable] Whether non-moderators can add other non-moderators to the thread (private threads only)
|
||||
* @arg {String} options.name The thread channel name
|
||||
* @arg {Number} [options.type] The channel type of the thread to create. It is recommended to explicitly set this property as this will be a required property in API v10
|
||||
* @returns {Promise<PrivateThreadChannel>}
|
||||
*/
|
||||
createThreadWithoutMessage(options) {
|
||||
return this.client.createThreadWithoutMessage.call(this.client, this.id, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a channel webhook
|
||||
* @arg {Object} options Webhook options
|
||||
* @arg {String} [options.avatar] The default avatar as a base64 data URI. Note: base64 strings alone are not base64 data URI strings
|
||||
* @arg {String} options.name The default name
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise<Object>} Resolves with a webhook object
|
||||
*/
|
||||
createWebhook(options, reason) {
|
||||
return this.client.createChannelWebhook.call(this.client, this.id, options, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise}
|
||||
*/
|
||||
deleteMessage(messageID, reason) {
|
||||
return this.client.deleteMessage.call(this.client, this.id, messageID, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk delete messages (bot accounts only)
|
||||
* @arg {Array<String>} messageIDs Array of message IDs to delete
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise}
|
||||
*/
|
||||
deleteMessages(messageIDs, reason) {
|
||||
return this.client.deleteMessages.call(this.client, this.id, messageIDs, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @arg {String | Array | Object} content A string, array of strings, or object. If an object is passed:
|
||||
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
||||
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
|
||||
* @arg {Array<Object>} [content.components] An array of component objects
|
||||
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 0-4 and type 3 only)
|
||||
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3 only)
|
||||
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
||||
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
||||
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
||||
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
||||
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
||||
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
||||
* @arg {String} [content.components[].options[].description] The description for this option
|
||||
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
||||
* @arg {String} content.components[].options[].label The label for this option
|
||||
* @arg {Number | String} content.components[].options[].value The value for this option
|
||||
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3 only)
|
||||
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
|
||||
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
|
||||
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
||||
* @arg {String} [content.content] A content string
|
||||
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Object | Array<Object>} [content.file] A file object (or an Array of them)
|
||||
* @arg {Buffer} content.file[].file A buffer containing file data
|
||||
* @arg {String} content.file[].name What to name the file
|
||||
* @arg {Number} [content.flags] A number representing the flags to apply to the message. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for flags reference
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
editMessage(messageID, content) {
|
||||
return this.client.editMessage.call(this.client, this.id, messageID, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* [DEPRECATED] Get all active threads in this channel. Use guild.getActiveThreads instead
|
||||
* @returns {Promise<Object>} An object containing an array of `threads`, an array of `members` and whether the response `hasMore` threads that could be returned in a subsequent call
|
||||
*/
|
||||
getActiveThreads() {
|
||||
return this.client.getActiveThreads.call(this.client, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all archived threads in this channel
|
||||
* @arg {String} type The type of thread channel, either "public" or "private"
|
||||
* @arg {Object} [options] Additional options when requesting archived threads
|
||||
* @arg {Date} [options.before] List of threads to return before the timestamp
|
||||
* @arg {Number} [options.limit] Maximum number of threads to return
|
||||
* @returns {Promise<Object>} An object containing an array of `threads`, an array of `members` and whether the response `hasMore` threads that could be returned in a subsequent call
|
||||
*/
|
||||
getArchivedThreads(type, options) {
|
||||
return this.client.getArchivedThreads.call(this.client, this.id, type, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all invites in the channel
|
||||
* @returns {Promise<Array<Invite>>}
|
||||
*/
|
||||
getInvites() {
|
||||
return this.client.getChannelInvites.call(this.client, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get joined private archived threads in this channel
|
||||
* @arg {Object} [options] Additional options when requesting archived threads
|
||||
* @arg {Date} [options.before] List of threads to return before the timestamp
|
||||
* @arg {Number} [options.limit] Maximum number of threads to return
|
||||
* @returns {Promise<Object>} An object containing an array of `threads`, an array of `members` and whether the response `hasMore` threads that could be returned in a subsequent call
|
||||
*/
|
||||
getJoinedPrivateArchivedThreads(options) {
|
||||
return this.client.getJoinedPrivateArchivedThreads.call(this.client, this.id, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a previous message in the channel
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
getMessage(messageID) {
|
||||
return this.client.getMessage.call(this.client, this.id, messageID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of users who reacted with a specific reaction
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
||||
* @arg {Object} [options] Options for the request. If this is a number, it is treated as `options.limit` ([DEPRECATED] behavior)
|
||||
* @arg {Number} [options.limit=100] The maximum number of users to get
|
||||
* @arg {String} [options.after] Get users after this user ID
|
||||
* @arg {String} [before] [DEPRECATED] Get users before this user ID. Discord no longer supports this parameter
|
||||
* @arg {String} [after] [DEPRECATED] Get users after this user ID
|
||||
* @returns {Promise<Array<User>>}
|
||||
*/
|
||||
getMessageReaction(messageID, reaction, options, before, after) {
|
||||
return this.client.getMessageReaction.call(this.client, this.id, messageID, reaction, options, before, after);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get previous messages in the channel
|
||||
* @arg {Object} [options] Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit`
|
||||
* @arg {String} [options.after] Get messages after this message ID
|
||||
* @arg {String} [options.around] Get messages around this message ID (does not work with limit > 100)
|
||||
* @arg {String} [options.before] Get messages before this message ID
|
||||
* @arg {Number} [options.limit=50] The max number of messages to get
|
||||
* @arg {String} [before] [DEPRECATED] Get messages before this message ID
|
||||
* @arg {String} [after] [DEPRECATED] Get messages after this message ID
|
||||
* @arg {String} [around] [DEPRECATED] Get messages around this message ID (does not work with limit > 100)
|
||||
* @returns {Promise<Array<Message>>}
|
||||
*/
|
||||
getMessages(options, before, after, around) {
|
||||
return this.client.getMessages.call(this.client, this.id, options, before, after, around);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the pins in the channel
|
||||
* @returns {Promise<Array<Message>>}
|
||||
*/
|
||||
getPins() {
|
||||
return this.client.getPins.call(this.client, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the webhooks in the channel
|
||||
* @returns {Promise<Array<Object>>} Resolves with an array of webhook objects
|
||||
*/
|
||||
getWebhooks() {
|
||||
return this.client.getChannelWebhooks.call(this.client, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pin a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @returns {Promise}
|
||||
*/
|
||||
pinMessage(messageID) {
|
||||
return this.client.pinMessage.call(this.client, this.id, messageID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge previous messages in the channel with an optional filter (bot accounts only)
|
||||
* @arg {Object} options Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit`
|
||||
* @arg {String} [options.after] Get messages after this message ID
|
||||
* @arg {String} [options.before] Get messages before this message ID
|
||||
* @arg {Function} [options.filter] Optional filter function that returns a boolean when passed a Message object
|
||||
* @arg {Number} options.limit The max number of messages to search through, -1 for no limit
|
||||
* @arg {String} [options.reason] The reason to be displayed in audit logs
|
||||
* @arg {Function} [filter] [DEPRECATED] Optional filter function that returns a boolean when passed a Message object
|
||||
* @arg {String} [before] [DEPRECATED] Get messages before this message ID
|
||||
* @arg {String} [after] [DEPRECATED] Get messages after this message ID
|
||||
* @arg {String} [reason] [DEPRECATED] The reason to be displayed in audit logs
|
||||
* @returns {Promise<Number>} Resolves with the number of messages deleted
|
||||
*/
|
||||
purge(limit, filter, before, after, reason) {
|
||||
return this.client.purgeChannel.call(this.client, this.id, limit, filter, before, after, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a reaction from a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
||||
* @arg {String} [userID="@me"] The ID of the user to remove the reaction for
|
||||
* @returns {Promise}
|
||||
*/
|
||||
removeMessageReaction(messageID, reaction, userID) {
|
||||
return this.client.removeMessageReaction.call(this.client, this.id, messageID, reaction, userID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all reactions from a message for a single emoji
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
||||
* @returns {Promise}
|
||||
*/
|
||||
removeMessageReactionEmoji(messageID, reaction) {
|
||||
return this.client.removeMessageReactionEmoji.call(this.client, this.id, messageID, reaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all reactions from a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @returns {Promise}
|
||||
*/
|
||||
removeMessageReactions(messageID) {
|
||||
return this.client.removeMessageReactions.call(this.client, this.id, messageID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send typing status in the channel
|
||||
* @returns {Promise}
|
||||
*/
|
||||
sendTyping() {
|
||||
return this.client.sendChannelTyping.call(this.client, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpin a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @returns {Promise}
|
||||
*/
|
||||
unpinMessage(messageID) {
|
||||
return this.client.unpinMessage.call(this.client, this.id, messageID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Un-send a message. You're welcome Programmix
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @returns {Promise}
|
||||
*/
|
||||
unsendMessage(messageID) {
|
||||
return this.client.deleteMessage.call(this.client, this.id, messageID);
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"lastMessageID",
|
||||
"lastPinTimestamp",
|
||||
"messages",
|
||||
"rateLimitPerUser",
|
||||
"topic",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TextChannel;
|
271
node_modules/eris/lib/structures/TextVoiceChannel.js
generated
vendored
Normal file
271
node_modules/eris/lib/structures/TextVoiceChannel.js
generated
vendored
Normal file
@ -0,0 +1,271 @@
|
||||
"use strict";
|
||||
|
||||
const VoiceChannel = require("./VoiceChannel");
|
||||
const Collection = require("../util/Collection");
|
||||
const Message = require("./Message");
|
||||
|
||||
/**
|
||||
* Represents a Text-in-Voice channel. See VoiceChannel for more properties and methods.
|
||||
* @extends VoiceChannel
|
||||
* @prop {String} lastMessageID The ID of the last message in this channel
|
||||
* @prop {Collection<Message>} messages Collection of Messages in this channel
|
||||
* @prop {Number} rateLimitPerUser The ratelimit of the channel, in seconds. 0 means no ratelimit is enabled
|
||||
*/
|
||||
class TextVoiceChannel extends VoiceChannel {
|
||||
constructor(data, client, messageLimit) {
|
||||
super(data, client);
|
||||
this.messages = new Collection(Message, messageLimit == null ? client.options.messageLimit : messageLimit);
|
||||
this.lastMessageID = data.last_message_id || null;
|
||||
this.rateLimitPerUser = data.rate_limit_per_user == null ? null : data.rate_limit_per_user;
|
||||
}
|
||||
|
||||
update(data) {
|
||||
super.update(data);
|
||||
// "not yet, possibly TBD"
|
||||
if(data.rate_limit_per_user !== undefined) {
|
||||
this.rateLimitPerUser = data.rate_limit_per_user;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a reaction to a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
||||
* @arg {String} [userID="@me"] The ID of the user to react as. Passing this parameter is deprecated and will not be supported in future versions.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
addMessageReaction(messageID, reaction, userID) {
|
||||
return this.client.addMessageReaction.call(this.client, this.id, messageID, reaction, userID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an invite for the channel
|
||||
* @arg {Object} [options] Invite generation options
|
||||
* @arg {Number} [options.maxAge] How long the invite should last in seconds
|
||||
* @arg {Number} [options.maxUses] How many uses the invite should last for
|
||||
* @arg {Boolean} [options.temporary] Whether the invite grants temporary membership or not
|
||||
* @arg {Boolean} [options.unique] Whether the invite is unique or not
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise<Invite>}
|
||||
*/
|
||||
createInvite(options, reason) {
|
||||
return this.client.createChannelInvite.call(this.client, this.id, options, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a message in the channel
|
||||
* Note: If you want to DM someone, the user ID is **not** the DM channel ID. use Client.getDMChannel() to get the DM channel ID for a user
|
||||
* @arg {String | Object} content A string or object. If an object is passed:
|
||||
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
||||
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
|
||||
* @arg {Boolean} [options.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to
|
||||
* @arg {Array<Object>} [content.components] An array of component objects
|
||||
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 0-4 and type 3 only)
|
||||
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3 only)
|
||||
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
||||
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
||||
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
||||
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
||||
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
||||
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
||||
* @arg {String} [content.components[].options[].description] The description for this option
|
||||
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
||||
* @arg {String} content.components[].options[].label The label for this option
|
||||
* @arg {Number | String} content.components[].options[].value The value for this option
|
||||
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3 only)
|
||||
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
|
||||
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
|
||||
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
||||
* @arg {String} content.content A content string
|
||||
* @arg {Object} [content.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure. Use `embeds` instead
|
||||
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Object} [content.messageReference] The message reference, used when replying to messages
|
||||
* @arg {String} [content.messageReference.channelID] The channel ID of the referenced message
|
||||
* @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message
|
||||
* @arg {String} [content.messageReference.guildID] The guild ID of the referenced message
|
||||
* @arg {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message
|
||||
* @arg {String} [content.messageReferenceID] [DEPRECATED] The ID of the message should be replied to. Use `messageReference` instead
|
||||
* @arg {Array<String>} [content.stickerIDs] An array of IDs corresponding to the stickers to send
|
||||
* @arg {Boolean} [content.tts] Set the message TTS flag
|
||||
* @arg {Object} [file] A file object
|
||||
* @arg {Buffer} file.file A buffer containing file data
|
||||
* @arg {String} file.name What to name the file
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
createMessage(content, file) {
|
||||
return this.client.createMessage.call(this.client, this.id, content, file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise}
|
||||
*/
|
||||
deleteMessage(messageID, reason) {
|
||||
return this.client.deleteMessage.call(this.client, this.id, messageID, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk delete messages (bot accounts only)
|
||||
* @arg {Array<String>} messageIDs Array of message IDs to delete
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise}
|
||||
*/
|
||||
deleteMessages(messageIDs, reason) {
|
||||
return this.client.deleteMessages.call(this.client, this.id, messageIDs, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @arg {String | Array | Object} content A string, array of strings, or object. If an object is passed:
|
||||
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
||||
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
|
||||
* @arg {Array<Object>} [content.components] An array of component objects
|
||||
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 0-4 and type 3 only)
|
||||
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3 only)
|
||||
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
||||
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
||||
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
||||
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
||||
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
||||
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
||||
* @arg {String} [content.components[].options[].description] The description for this option
|
||||
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
||||
* @arg {String} content.components[].options[].label The label for this option
|
||||
* @arg {Number | String} content.components[].options[].value The value for this option
|
||||
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3 only)
|
||||
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
|
||||
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
|
||||
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
||||
* @arg {String} content.content A content string
|
||||
* @arg {Boolean} [content.disableEveryone] Whether to filter @everyone/@here or not (overrides default)
|
||||
* @arg {Object} [content.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure. Use `embeds` instead
|
||||
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Number} [content.flags] A number representing the flags to apply to the message. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for flags reference
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
editMessage(messageID, content) {
|
||||
return this.client.editMessage.call(this.client, this.id, messageID, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all invites in the channel
|
||||
* @returns {Promise<Array<Invite>>}
|
||||
*/
|
||||
getInvites() {
|
||||
return this.client.getChannelInvites.call(this.client, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a previous message in the channel
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
getMessage(messageID) {
|
||||
return this.client.getMessage.call(this.client, this.id, messageID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of users who reacted with a specific reaction
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
||||
* @arg {Object} [options] Options for the request. If this is a number, it is treated as `options.limit` ([DEPRECATED] behavior)
|
||||
* @arg {Number} [options.limit=100] The maximum number of users to get
|
||||
* @arg {String} [options.after] Get users after this user ID
|
||||
* @arg {String} [before] [DEPRECATED] Get users before this user ID. Discord no longer supports this parameter
|
||||
* @arg {String} [after] [DEPRECATED] Get users after this user ID
|
||||
* @returns {Promise<Array<User>>}
|
||||
*/
|
||||
getMessageReaction(messageID, reaction, options, before, after) {
|
||||
return this.client.getMessageReaction.call(this.client, this.id, messageID, reaction, options, before, after);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get previous messages in the channel
|
||||
* @arg {Object} [options] Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit`
|
||||
* @arg {String} [options.after] Get messages after this message ID
|
||||
* @arg {String} [options.around] Get messages around this message ID (does not work with limit > 100)
|
||||
* @arg {String} [options.before] Get messages before this message ID
|
||||
* @arg {Number} [options.limit=50] The max number of messages to get
|
||||
* @arg {String} [before] [DEPRECATED] Get messages before this message ID
|
||||
* @arg {String} [after] [DEPRECATED] Get messages after this message ID
|
||||
* @arg {String} [around] [DEPRECATED] Get messages around this message ID (does not work with limit > 100)
|
||||
* @returns {Promise<Array<Message>>}
|
||||
*/
|
||||
getMessages(options, before, after, around) {
|
||||
return this.client.getMessages.call(this.client, this.id, options, before, after, around);
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge previous messages in the channel with an optional filter (bot accounts only)
|
||||
* @arg {Object} options Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit`
|
||||
* @arg {String} [options.after] Get messages after this message ID
|
||||
* @arg {String} [options.before] Get messages before this message ID
|
||||
* @arg {Function} [options.filter] Optional filter function that returns a boolean when passed a Message object
|
||||
* @arg {Number} options.limit The max number of messages to search through, -1 for no limit
|
||||
* @arg {String} [options.reason] The reason to be displayed in audit logs
|
||||
* @arg {Function} [filter] [DEPRECATED] Optional filter function that returns a boolean when passed a Message object
|
||||
* @arg {String} [before] [DEPRECATED] Get messages before this message ID
|
||||
* @arg {String} [after] [DEPRECATED] Get messages after this message ID
|
||||
* @arg {String} [reason] [DEPRECATED] The reason to be displayed in audit logs
|
||||
* @returns {Promise<Number>} Resolves with the number of messages deleted
|
||||
*/
|
||||
purge(limit, filter, before, after, reason) {
|
||||
return this.client.purgeChannel.call(this.client, this.id, limit, filter, before, after, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a reaction from a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
||||
* @arg {String} [userID="@me"] The ID of the user to remove the reaction for
|
||||
* @returns {Promise}
|
||||
*/
|
||||
removeMessageReaction(messageID, reaction, userID) {
|
||||
return this.client.removeMessageReaction.call(this.client, this.id, messageID, reaction, userID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all reactions from a message for a single emoji
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
||||
* @returns {Promise}
|
||||
*/
|
||||
removeMessageReactionEmoji(messageID, reaction) {
|
||||
return this.client.removeMessageReactionEmoji.call(this.client, this.id, messageID, reaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all reactions from a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @returns {Promise}
|
||||
*/
|
||||
removeMessageReactions(messageID) {
|
||||
return this.client.removeMessageReactions.call(this.client, this.id, messageID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send typing status in the channel
|
||||
* @returns {Promise}
|
||||
*/
|
||||
sendTyping() {
|
||||
return this.client.sendChannelTyping.call(this.client, this.id);
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"lastMessageID",
|
||||
"messages",
|
||||
"rateLimitPerUser",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TextVoiceChannel;
|
344
node_modules/eris/lib/structures/ThreadChannel.js
generated
vendored
Normal file
344
node_modules/eris/lib/structures/ThreadChannel.js
generated
vendored
Normal file
@ -0,0 +1,344 @@
|
||||
"use strict";
|
||||
|
||||
const Collection = require("../util/Collection");
|
||||
const GuildChannel = require("./GuildChannel");
|
||||
const Message = require("./Message");
|
||||
const ThreadMember = require("./ThreadMember");
|
||||
|
||||
/**
|
||||
* Represents a thread channel. You also probably want to look at NewsThreadChannel, PublicThreadChannel, and PrivateThreadChannel. See GuildChannel for extra properties.
|
||||
* @extends GuildChannel
|
||||
* @prop {String} lastMessageID The ID of the last message in this channel
|
||||
* @prop {Object?} member Thread member for the current user, if they have joined the thread
|
||||
* @prop {Number} member.flags The user's thread settings
|
||||
* @prop {String} member.id The ID of the thread
|
||||
* @prop {Number} member.joinTimestamp The time the user last joined the thread
|
||||
* @prop {String} member.userID The ID of the user
|
||||
* @prop {Number} memberCount An approximate number of users in the thread (stops at 50)
|
||||
* @prop {Collection<ThreadMember>} members Collection of members in this channel
|
||||
* @prop {Number} messageCount An approximate number of messages in the thread (stops at 50)
|
||||
* @prop {Collection<Message>} messages Collection of Messages in this channel
|
||||
* @prop {String} ownerID The ID of the user that created the thread
|
||||
* @prop {Number} rateLimitPerUser The ratelimit of the channel, in seconds. 0 means no ratelimit is enabled
|
||||
* @prop {Object} threadMetadata Metadata for the thread
|
||||
* @prop {Number} threadMetadata.archiveTimestamp Timestamp when the thread's archive status was last changed, used for calculating recent activity
|
||||
* @prop {Boolean} threadMetadata.archived Whether the thread is archived
|
||||
* @prop {Number} threadMetadata.autoArchiveDuration Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080
|
||||
* @prop {Boolean} threadMetadata.locked Whether the thread is locked
|
||||
*/
|
||||
class ThreadChannel extends GuildChannel {
|
||||
constructor(data, client, messageLimit) {
|
||||
super(data, client);
|
||||
this.messages = new Collection(Message, messageLimit == null ? client.options.messageLimit : messageLimit);
|
||||
this.members = new Collection(ThreadMember);
|
||||
this.lastMessageID = data.last_message_id || null;
|
||||
this.ownerID = data.owner_id;
|
||||
this.update(data);
|
||||
}
|
||||
|
||||
update(data) {
|
||||
super.update(data);
|
||||
if(data.member_count !== undefined) {
|
||||
this.memberCount = data.member_count;
|
||||
}
|
||||
if(data.message_count !== undefined) {
|
||||
this.messageCount = data.message_count;
|
||||
}
|
||||
if(data.rate_limit_per_user !== undefined) {
|
||||
this.rateLimitPerUser = data.rate_limit_per_user;
|
||||
}
|
||||
if(data.thread_metadata !== undefined) {
|
||||
this.threadMetadata = {
|
||||
archiveTimestamp: Date.parse(data.thread_metadata.archive_timestamp),
|
||||
archived: data.thread_metadata.archived,
|
||||
autoArchiveDuration: data.thread_metadata.auto_archive_duration,
|
||||
locked: data.thread_metadata.locked
|
||||
};
|
||||
}
|
||||
if(data.member !== undefined) {
|
||||
this.member = new ThreadMember(data.member, this.client);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a reaction to a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
||||
* @returns {Promise}
|
||||
*/
|
||||
addMessageReaction(messageID, reaction) {
|
||||
return this.client.addMessageReaction.call(this.client, this.id, messageID, reaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a message in the channel
|
||||
* @arg {String | Object} content A string or object. If an object is passed:
|
||||
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
||||
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
|
||||
* @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to.
|
||||
* @arg {Array<Object>} [content.components] An array of component objects
|
||||
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 0-4 and type 3 only)
|
||||
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3 only)
|
||||
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
||||
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
||||
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
||||
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
||||
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
||||
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
||||
* @arg {String} [content.components[].options[].description] The description for this option
|
||||
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
||||
* @arg {String} content.components[].options[].label The label for this option
|
||||
* @arg {Number | String} content.components[].options[].value The value for this option
|
||||
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3 only)
|
||||
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
|
||||
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
|
||||
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
||||
* @arg {String} [content.content] A content string
|
||||
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Object} [content.messageReference] The message reference, used when replying to messages
|
||||
* @arg {String} [content.messageReference.channelID] The channel ID of the referenced message
|
||||
* @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message
|
||||
* @arg {String} [content.messageReference.guildID] The guild ID of the referenced message
|
||||
* @arg {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message
|
||||
* @arg {String} [content.messageReferenceID] [DEPRECATED] The ID of the message should be replied to. Use `messageReference` instead
|
||||
* @arg {Array<String>} [content.stickerIDs] An array of IDs corresponding to stickers to send
|
||||
* @arg {Boolean} [content.tts] Set the message TTS flag
|
||||
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
||||
* @arg {Buffer} file.file A buffer containing file data
|
||||
* @arg {String} file.name What to name the file
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
createMessage(content, file) {
|
||||
return this.client.createMessage.call(this.client, this.id, content, file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise}
|
||||
*/
|
||||
deleteMessage(messageID, reason) {
|
||||
return this.client.deleteMessage.call(this.client, this.id, messageID, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk delete messages (bot accounts only)
|
||||
* @arg {Array<String>} messageIDs Array of message IDs to delete
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise}
|
||||
*/
|
||||
deleteMessages(messageIDs, reason) {
|
||||
return this.client.deleteMessages.call(this.client, this.id, messageIDs, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @arg {String | Array | Object} content A string, array of strings, or object. If an object is passed:
|
||||
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
||||
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
|
||||
* @arg {Array<Object>} [content.components] An array of component objects
|
||||
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 0-4 and type 3 only)
|
||||
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3 only)
|
||||
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
||||
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
||||
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
||||
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
||||
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
||||
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
||||
* @arg {String} [content.components[].options[].description] The description for this option
|
||||
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
||||
* @arg {String} content.components[].options[].label The label for this option
|
||||
* @arg {Number | String} content.components[].options[].value The value for this option
|
||||
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3 only)
|
||||
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
|
||||
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
|
||||
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
||||
* @arg {String} [content.content] A content string
|
||||
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Object | Array<Object>} [content.file] A file object (or an Array of them)
|
||||
* @arg {Buffer} content.file[].file A buffer containing file data
|
||||
* @arg {String} content.file[].name What to name the file
|
||||
* @arg {Number} [content.flags] A number representing the flags to apply to the message. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for flags reference
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
editMessage(messageID, content) {
|
||||
return this.client.editMessage.call(this.client, this.id, messageID, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of members that are part of this thread channel
|
||||
* @returns {Promise<Array<ThreadMember>>}
|
||||
*/
|
||||
getMembers() {
|
||||
return this.client.getThreadMembers.call(this.client, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a previous message in the channel
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
getMessage(messageID) {
|
||||
return this.client.getMessage.call(this.client, this.id, messageID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of users who reacted with a specific reaction
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
||||
* @arg {Object} [options] Options for the request. If this is a number, it is treated as `options.limit` ([DEPRECATED] behavior)
|
||||
* @arg {Number} [options.limit=100] The maximum number of users to get
|
||||
* @arg {String} [options.after] Get users after this user ID
|
||||
* @arg {String} [before] [DEPRECATED] Get users before this user ID. Discord no longer supports this parameter
|
||||
* @arg {String} [after] [DEPRECATED] Get users after this user ID
|
||||
* @returns {Promise<Array<User>>}
|
||||
*/
|
||||
getMessageReaction(messageID, reaction, options, before, after) {
|
||||
return this.client.getMessageReaction.call(this.client, this.id, messageID, reaction, options, before, after);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get previous messages in the channel
|
||||
* @arg {Object} [options] Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit`
|
||||
* @arg {String} [options.after] Get messages after this message ID
|
||||
* @arg {String} [options.around] Get messages around this message ID (does not work with limit > 100)
|
||||
* @arg {String} [options.before] Get messages before this message ID
|
||||
* @arg {Number} [options.limit=50] The max number of messages to get
|
||||
* @arg {String} [before] [DEPRECATED] Get messages before this message ID
|
||||
* @arg {String} [after] [DEPRECATED] Get messages after this message ID
|
||||
* @arg {String} [around] [DEPRECATED] Get messages around this message ID (does not work with limit > 100)
|
||||
* @returns {Promise<Array<Message>>}
|
||||
*/
|
||||
getMessages(options, before, after, around) {
|
||||
return this.client.getMessages.call(this.client, this.id, options, before, after, around);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the pins in the channel
|
||||
* @returns {Promise<Array<Message>>}
|
||||
*/
|
||||
getPins() {
|
||||
return this.client.getPins.call(this.client, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Join a thread
|
||||
* @arg {String} [userID="@me"] The user ID of the user joining
|
||||
* @returns {Promise}
|
||||
*/
|
||||
join(userID) {
|
||||
return this.client.joinThread.call(this.client, this.id, userID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Leave a thread
|
||||
* @arg {String} [userID="@me"] The user ID of the user leaving
|
||||
* @returns {Promise}
|
||||
*/
|
||||
leave(userID) {
|
||||
return this.client.leaveThread.call(this.client, this.id, userID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pin a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @returns {Promise}
|
||||
*/
|
||||
pinMessage(messageID) {
|
||||
return this.client.pinMessage.call(this.client, this.id, messageID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge previous messages in the channel with an optional filter (bot accounts only)
|
||||
* @arg {Object} options Options for the request. If this is a number
|
||||
* @arg {String} [options.after] Get messages after this message ID
|
||||
* @arg {String} [options.before] Get messages before this message ID
|
||||
* @arg {Function} [options.filter] Optional filter function that returns a boolean when passed a Message object
|
||||
* @arg {Number} options.limit The max number of messages to search through, -1 for no limit
|
||||
* @arg {String} [options.reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise<Number>} Resolves with the number of messages deleted
|
||||
*/
|
||||
purge(options) {
|
||||
return this.client.purgeChannel.call(this.client, this.id, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a reaction from a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
||||
* @arg {String} [userID="@me"] The ID of the user to remove the reaction for
|
||||
* @returns {Promise}
|
||||
*/
|
||||
removeMessageReaction(messageID, reaction, userID) {
|
||||
return this.client.removeMessageReaction.call(this.client, this.id, messageID, reaction, userID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all reactions from a message for a single emoji
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
||||
* @returns {Promise}
|
||||
*/
|
||||
removeMessageReactionEmoji(messageID, reaction) {
|
||||
return this.client.removeMessageReactionEmoji.call(this.client, this.id, messageID, reaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all reactions from a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @returns {Promise}
|
||||
*/
|
||||
removeMessageReactions(messageID) {
|
||||
return this.client.removeMessageReactions.call(this.client, this.id, messageID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send typing status in the channel
|
||||
* @returns {Promise}
|
||||
*/
|
||||
sendTyping() {
|
||||
return this.client.sendChannelTyping.call(this.client, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpin a message
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @returns {Promise}
|
||||
*/
|
||||
unpinMessage(messageID) {
|
||||
return this.client.unpinMessage.call(this.client, this.id, messageID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Un-send a message. You're welcome Programmix
|
||||
* @arg {String} messageID The ID of the message
|
||||
* @returns {Promise}
|
||||
*/
|
||||
unsendMessage(messageID) {
|
||||
return this.client.deleteMessage.call(this.client, this.id, messageID);
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"lastMessageID",
|
||||
"memberCount",
|
||||
"messageCount",
|
||||
"messages",
|
||||
"ownerID",
|
||||
"rateLimitPerUser",
|
||||
"threadMetadata",
|
||||
"member",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ThreadChannel;
|
55
node_modules/eris/lib/structures/ThreadMember.js
generated
vendored
Normal file
55
node_modules/eris/lib/structures/ThreadMember.js
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
|
||||
const Base = require("./Base");
|
||||
|
||||
/**
|
||||
* Represents a thread member
|
||||
* @prop {Number} flags The user-thread settings of this member
|
||||
* @prop {Member?} guildMember The guild member that this thread member belongs to. This will never be present when fetching over REST
|
||||
* @prop {String} id The ID of the thread member
|
||||
* @prop {Number} joinTimestamp Timestamp of when the member joined the thread
|
||||
* @prop {String} threadID The ID of the thread this member is a part of
|
||||
*/
|
||||
class ThreadMember extends Base {
|
||||
constructor(data, client) {
|
||||
super(data.user_id);
|
||||
this._client = client;
|
||||
this.flags = data.flags;
|
||||
this.threadID = data.thread_id || data.id; // Thanks Discord
|
||||
this.joinTimestamp = Date.parse(data.join_timestamp);
|
||||
|
||||
if(data.guild_member !== undefined) {
|
||||
const guild = this._client.guilds.get(this._client.threadGuildMap[this.threadID]);
|
||||
this.guildMember = guild.members.update(data.guild_member, guild);
|
||||
if(data.presence !== undefined) {
|
||||
this.guildMember.update(data.presence);
|
||||
}
|
||||
}
|
||||
|
||||
this.update(data);
|
||||
}
|
||||
|
||||
update(data) {
|
||||
if(data.flags !== undefined) {
|
||||
this.flags = data.flags;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the member from the thread
|
||||
* @returns {Promise}
|
||||
*/
|
||||
leave() {
|
||||
return this._client.leaveThread.call(this._client, this.threadID, this.id);
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"threadID",
|
||||
"joinTimestamp",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ThreadMember;
|
26
node_modules/eris/lib/structures/UnavailableGuild.js
generated
vendored
Normal file
26
node_modules/eris/lib/structures/UnavailableGuild.js
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
|
||||
const Base = require("./Base");
|
||||
|
||||
/**
|
||||
* Represents a guild
|
||||
* @prop {String} id The ID of the guild
|
||||
* @prop {Boolean} unavailable Whether the guild is unavailable or not
|
||||
* @prop {Shard} shard The Shard that owns the guild
|
||||
*/
|
||||
class UnavailableGuild extends Base {
|
||||
constructor(data, client) {
|
||||
super(data.id);
|
||||
this.shard = client.shards.get(client.guildShardMap[this.id]);
|
||||
this.unavailable = !!data.unavailable;
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"unavailable",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = UnavailableGuild;
|
453
node_modules/eris/lib/structures/UnknownInteraction.js
generated
vendored
Normal file
453
node_modules/eris/lib/structures/UnknownInteraction.js
generated
vendored
Normal file
@ -0,0 +1,453 @@
|
||||
"use strict";
|
||||
|
||||
const Interaction = require("./Interaction");
|
||||
const Message = require("./Message");
|
||||
const Member = require("./Member");
|
||||
const Permission = require("./Permission");
|
||||
const {InteractionResponseTypes} = require("../Constants");
|
||||
|
||||
/**
|
||||
* Represents an unknown interaction. See Interaction for more properties.
|
||||
* Note: Methods are not guaranteed to work properly, they are all added just in case you know which to use.
|
||||
* @extends Interaction
|
||||
* @prop {Permission?} appPermissions The permissions the app or bot has within the channel the interaction was sent from
|
||||
* @prop {(PrivateChannel | TextChannel | NewsChannel)?} channel The channel the interaction was created in. Can be partial with only the id if the channel is not cached.
|
||||
* @prop {Object?} data The data attached to the interaction
|
||||
* @prop {String?} guildID The ID of the guild in which the interaction was created
|
||||
* @prop {Member?} member The member who triggered the interaction (This is only sent when the interaction is invoked within a guild)
|
||||
* @prop {Message?} message The message the interaction came from (Message Component only). If the message is ephemeral, this will be an object with `id` and `flags` keys.
|
||||
* @prop {User?} user The user who triggered the interaction (This is only sent when the interaction is invoked within a dm)
|
||||
*/
|
||||
class UnknownInteraction extends Interaction {
|
||||
constructor(info, client) {
|
||||
super(info, client);
|
||||
|
||||
if(info.channel_id !== undefined) {
|
||||
this.channel = this._client.getChannel(info.channel_id) || {
|
||||
id: info.channel_id
|
||||
};
|
||||
}
|
||||
|
||||
if(info.data !== undefined) {
|
||||
this.data = info.data;
|
||||
}
|
||||
|
||||
if(info.guild_id !== undefined) {
|
||||
this.guildID = info.guild_id;
|
||||
}
|
||||
|
||||
if(info.member !== undefined) {
|
||||
if(this.channel.guild) {
|
||||
info.member.id = info.member.user.id;
|
||||
this.member = this.channel.guild.members.update(info.member, this.channel.guild);
|
||||
} else {
|
||||
const guild = this._client.guilds.get(info.guild_id);
|
||||
this.member = new Member(info.member, guild, this._client);
|
||||
}
|
||||
}
|
||||
|
||||
if(info.message !== undefined) {
|
||||
this.message = new Message(info.message, this._client);
|
||||
}
|
||||
|
||||
if(info.user !== undefined) {
|
||||
this.user = this._client.users.update(info.user, client);
|
||||
}
|
||||
|
||||
if(info.app_permissions !== undefined) {
|
||||
this.appPermissions = new Permission(info.app_permissions);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Acknowledges the autocomplete interaction with a result of choices.
|
||||
* Note: You can **not** use more than 1 initial interaction response per interaction.
|
||||
* @arg {Object} data The data object
|
||||
* @arg {Number} data.type The type of [interaction response](https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type) to send
|
||||
* @arg {Object} data.data The data to return to discord
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async acknowledge(data) {
|
||||
if(this.acknowledged === true) {
|
||||
throw new Error("You have already acknowledged this interaction.");
|
||||
}
|
||||
return this._client.createInteractionResponse.call(this._client, this.id, this.token, data).then(() => this.update());
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond to the interaction with a followup message
|
||||
* @arg {String | Object} content A string or object. If an object is passed:
|
||||
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
||||
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
|
||||
* @arg {Array<Object>} [content.components] An array of component objects
|
||||
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 0-4 and type 3 only)
|
||||
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3 only)
|
||||
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
||||
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
||||
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
||||
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
||||
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
||||
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
||||
* @arg {String} [content.components[].options[].description] The description for this option
|
||||
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
||||
* @arg {String} content.components[].options[].label The label for this option
|
||||
* @arg {Number | String} content.components[].options[].value The value for this option
|
||||
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3 only)
|
||||
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
|
||||
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
|
||||
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
||||
* @arg {String} [content.content] A content string
|
||||
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Array<Object>} [options.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Number} [content.flags] 64 for Ephemeral
|
||||
* @arg {Boolean} [content.tts] Set the message TTS flag
|
||||
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
||||
* @arg {Buffer} file.file A buffer containing file data
|
||||
* @arg {String} file.name What to name the file
|
||||
* @returns {Promise<Message?>}
|
||||
*/
|
||||
async createFollowup(content, file) {
|
||||
if(this.acknowledged === false) {
|
||||
throw new Error("createFollowup cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, editParent, pong, or result first.");
|
||||
}
|
||||
if(content !== undefined) {
|
||||
if(typeof content !== "object" || content === null) {
|
||||
content = {
|
||||
content: "" + content
|
||||
};
|
||||
} else if(content.content !== undefined && typeof content.content !== "string") {
|
||||
content.content = "" + content.content;
|
||||
}
|
||||
}
|
||||
if(file) {
|
||||
content.file = file;
|
||||
}
|
||||
return this._client.executeWebhook.call(this._client, this.applicationID, this.token, Object.assign({wait: true}, content));
|
||||
}
|
||||
|
||||
/**
|
||||
* Acknowledges the interaction with a message. If already acknowledged runs createFollowup
|
||||
* Note: You can **not** use more than 1 initial interaction response per interaction, use createFollowup if you have already responded with a different interaction response.
|
||||
* @arg {String | Object} content A string or object. If an object is passed:
|
||||
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
||||
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
|
||||
* @arg {Array<Object>} [content.components] An array of component objects
|
||||
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 0-4 and type 3 only)
|
||||
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3 only)
|
||||
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
||||
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
||||
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
||||
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
||||
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
||||
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
||||
* @arg {String} [content.components[].options[].description] The description for this option
|
||||
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
||||
* @arg {String} content.components[].options[].label The label for this option
|
||||
* @arg {Number | String} content.components[].options[].value The value for this option
|
||||
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3 only)
|
||||
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
|
||||
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
|
||||
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
||||
* @arg {String} [content.content] A content string
|
||||
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Boolean} [content.flags] 64 for Ephemeral
|
||||
* @arg {Boolean} [content.tts] Set the message TTS flag
|
||||
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
||||
* @arg {Buffer} file.file A buffer containing file data
|
||||
* @arg {String} file.name What to name the file
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async createMessage(content, file) {
|
||||
if(this.acknowledged === true) {
|
||||
return this.createFollowup(content, file);
|
||||
}
|
||||
if(content !== undefined) {
|
||||
if(typeof content !== "object" || content === null) {
|
||||
content = {
|
||||
content: "" + content
|
||||
};
|
||||
} else if(content.content !== undefined && typeof content.content !== "string") {
|
||||
content.content = "" + content.content;
|
||||
}
|
||||
if(content.content !== undefined || content.embeds || content.allowedMentions) {
|
||||
content.allowed_mentions = this._client._formatAllowedMentions(content.allowedMentions);
|
||||
}
|
||||
}
|
||||
return this._client.createInteractionResponse.call(this._client, this.id, this.token, {
|
||||
type: InteractionResponseTypes.CHANNEL_MESSAGE_WITH_SOURCE,
|
||||
data: content
|
||||
}, file).then(() => this.update());
|
||||
}
|
||||
|
||||
/**
|
||||
* Acknowledges the interaction with a defer response
|
||||
* Note: You can **not** use more than 1 initial interaction response per interaction.
|
||||
* @arg {Number} [flags] 64 for Ephemeral
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async defer(flags) {
|
||||
if(this.acknowledged === true) {
|
||||
throw new Error("You have already acknowledged this interaction.");
|
||||
}
|
||||
return this._client.createInteractionResponse.call(this._client, this.id, this.token, {
|
||||
type: InteractionResponseTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE,
|
||||
data: {
|
||||
flags: flags || 0
|
||||
}
|
||||
}).then(() => this.update());
|
||||
}
|
||||
|
||||
/**
|
||||
* Acknowledges the interaction with a defer message update response (Message Component only)
|
||||
* Note: You can **not** use more than 1 initial interaction response per interaction.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async deferUpdate() {
|
||||
if(this.acknowledged === true) {
|
||||
throw new Error("You have already acknowledged this interaction.");
|
||||
}
|
||||
return this._client.createInteractionResponse.call(this._client, this.id, this.token, {
|
||||
type: InteractionResponseTypes.DEFERRED_UPDATE_MESSAGE
|
||||
}).then(() => this.update());
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a message
|
||||
* @arg {String} messageID the id of the message to delete, or "@original" for the original response.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async deleteMessage(messageID) {
|
||||
if(this.acknowledged === false) {
|
||||
throw new Error("deleteMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, editParent, or pong first.");
|
||||
}
|
||||
return this._client.deleteWebhookMessage.call(this._client, this.applicationID, this.token, messageID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the Original message (or the parent message for components)
|
||||
* Warning: Will error with ephemeral messages.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async deleteOriginalMessage() {
|
||||
if(this.acknowledged === false) {
|
||||
throw new Error("deleteOriginalMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, editParent, or pong first.");
|
||||
}
|
||||
return this._client.deleteWebhookMessage.call(this._client, this.applicationID, this.token, "@original");
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a message
|
||||
* @arg {String} messageID the id of the message to edit, or "@original" for the original response.
|
||||
* @arg {Object} content Interaction message edit options
|
||||
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
||||
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
|
||||
* @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
|
||||
* @arg {Array<Object>} [content.components] An array of component objects
|
||||
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 0-4 and type 3 only)
|
||||
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3 only)
|
||||
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
||||
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
||||
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
||||
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
||||
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
||||
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
||||
* @arg {String} [content.components[].options[].description] The description for this option
|
||||
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
||||
* @arg {String} content.components[].options[].label The label for this option
|
||||
* @arg {Number | String} content.components[].options[].value The value for this option
|
||||
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3 only)
|
||||
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
|
||||
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
|
||||
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
||||
* @arg {String} [content.content] A content string
|
||||
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
||||
* @arg {Buffer} file.file A buffer containing file data
|
||||
* @arg {String} file.name What to name the file
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
async editMessage(messageID, content, file) {
|
||||
if(this.acknowledged === false) {
|
||||
throw new Error("editMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, editParent, pong, or result first.");
|
||||
}
|
||||
if(content !== undefined) {
|
||||
if(typeof content !== "object" || content === null) {
|
||||
content = {
|
||||
content: "" + content
|
||||
};
|
||||
} else if(content.content !== undefined && typeof content.content !== "string") {
|
||||
content.content = "" + content.content;
|
||||
}
|
||||
}
|
||||
if(file) {
|
||||
content.file = file;
|
||||
}
|
||||
return this._client.editWebhookMessage.call(this._client, this.applicationID, this.token, messageID, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit the Original response message
|
||||
* @arg {Object} content Interaction message edit options (or the parent message for components)
|
||||
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
||||
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
|
||||
* @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
|
||||
* @arg {Array<Object>} [content.components] An array of component objects
|
||||
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 0-4 and type 3 only)
|
||||
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3 only)
|
||||
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
||||
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
||||
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
||||
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
||||
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
||||
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
||||
* @arg {String} [content.components[].options[].description] The description for this option
|
||||
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
||||
* @arg {String} content.components[].options[].label The label for this option
|
||||
* @arg {Number | String} content.components[].options[].value The value for this option
|
||||
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3 only)
|
||||
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
|
||||
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
|
||||
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
||||
* @arg {String} [content.content] A content string
|
||||
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
||||
* @arg {Buffer} file.file A buffer containing file data
|
||||
* @arg {String} file.name What to name the file
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
async editOriginalMessage(content, file) {
|
||||
if(this.acknowledged === false) {
|
||||
throw new Error("editOriginalMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, editParent, pong, or result first.");
|
||||
}
|
||||
if(content !== undefined) {
|
||||
if(typeof content !== "object" || content === null) {
|
||||
content = {
|
||||
content: "" + content
|
||||
};
|
||||
} else if(content.content !== undefined && typeof content.content !== "string") {
|
||||
content.content = "" + content.content;
|
||||
}
|
||||
}
|
||||
if(file) {
|
||||
content.file = file;
|
||||
}
|
||||
return this._client.editWebhookMessage.call(this._client, this.applicationID, this.token, "@original", content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Acknowledges the interaction by editing the parent message. If already acknowledged runs editOriginalMessage (Message Component only)
|
||||
* Note: You can **not** use more than 1 initial interaction response per interaction, use edit if you have already responded with a different interaction response.
|
||||
* Warning: Will error with ephemeral messages.
|
||||
* @arg {String | Object} content What to edit the message with
|
||||
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
||||
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
|
||||
* @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
|
||||
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
|
||||
* @arg {Array<Object>} [content.components] An array of component objects
|
||||
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 0-4 and type 3 only)
|
||||
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3 only)
|
||||
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
||||
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
||||
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
||||
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
||||
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
||||
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
||||
* @arg {String} [content.components[].options[].description] The description for this option
|
||||
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
||||
* @arg {String} content.components[].options[].label The label for this option
|
||||
* @arg {Number | String} content.components[].options[].value The value for this option
|
||||
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3 only)
|
||||
* @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 0-4, `custom_id` is required; if 5, `url` is required
|
||||
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
|
||||
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
||||
* @arg {String} [content.content] A content string
|
||||
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
||||
* @arg {Boolean} [content.flags] 64 for Ephemeral
|
||||
* @arg {Boolean} [content.tts] Set the message TTS flag
|
||||
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
||||
* @arg {Buffer} file.file A buffer containing file data
|
||||
* @arg {String} file.name What to name the file
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async editParent(content, file) {
|
||||
if(this.acknowledged === true) {
|
||||
return this.editOriginalMessage(content);
|
||||
}
|
||||
if(content !== undefined) {
|
||||
if(typeof content !== "object" || content === null) {
|
||||
content = {
|
||||
content: "" + content
|
||||
};
|
||||
} else if(content.content !== undefined && typeof content.content !== "string") {
|
||||
content.content = "" + content.content;
|
||||
}
|
||||
if(content.content !== undefined || content.embeds || content.allowedMentions) {
|
||||
content.allowed_mentions = this._client._formatAllowedMentions(content.allowedMentions);
|
||||
}
|
||||
}
|
||||
return this._client.createInteractionResponse.call(this._client, this.id, this.token, {
|
||||
type: InteractionResponseTypes.UPDATE_MESSAGE,
|
||||
data: content
|
||||
}, file).then(() => this.update());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Original response message (or the parent message for components)
|
||||
* Warning: Will error with ephemeral messages.
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
async getOriginalMessage() {
|
||||
if(this.acknowledged === false) {
|
||||
throw new Error("getOriginalMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, editParent, or pong first.");
|
||||
}
|
||||
return this._client.getWebhookMessage.call(this._client, this.applicationID, this.token, "@original");
|
||||
}
|
||||
|
||||
/**
|
||||
* Acknowledges the ping interaction with a pong response (Ping Only)
|
||||
* Note: You can **not** use more than 1 initial interaction response per interaction.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async pong() {
|
||||
if(this.acknowledged === true) {
|
||||
throw new Error("You have already acknowledged this interaction.");
|
||||
}
|
||||
return this._client.createInteractionResponse.call(this._client, this.id, this.token, {
|
||||
type: InteractionResponseTypes.PONG
|
||||
}).then(() => this.update());
|
||||
}
|
||||
|
||||
/**
|
||||
* Acknowledges the autocomplete interaction with a result of choices.
|
||||
* Note: You can **not** use more than 1 initial interaction response per interaction.
|
||||
* @arg {Array<Object>} choices The autocomplete choices to return to the user
|
||||
* @arg {String | Number} choices[].name The choice display name
|
||||
* @arg {String} choices[].value The choice value to return to the bot
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async result(choices) {
|
||||
if(this.acknowledged === true) {
|
||||
throw new Error("You have already acknowledged this interaction.");
|
||||
}
|
||||
return this._client.createInteractionResponse.call(this._client, this.id, this.token, {
|
||||
type: InteractionResponseTypes.APPLICATION_COMMAND_AUTOCOMPLETE_RESULT,
|
||||
data: {choices}
|
||||
}).then(() => this.update());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = UnknownInteraction;
|
190
node_modules/eris/lib/structures/User.js
generated
vendored
Normal file
190
node_modules/eris/lib/structures/User.js
generated
vendored
Normal file
@ -0,0 +1,190 @@
|
||||
"use strict";
|
||||
|
||||
const Base = require("./Base");
|
||||
const Endpoints = require("../rest/Endpoints");
|
||||
|
||||
/**
|
||||
* Represents a user
|
||||
* @prop {Number?} accentColor The user's banner color, or null if no banner color (REST only)
|
||||
* @prop {String?} avatar The hash of the user's avatar, or null if no avatar
|
||||
* @prop {String} avatarURL The URL of the user's avatar which can be either a JPG or GIF
|
||||
* @prop {String?} banner The hash of the user's banner, or null if no banner (REST only)
|
||||
* @prop {String?} bannerURL The URL of the user's banner
|
||||
* @prop {Boolean} bot Whether the user is an OAuth bot or not
|
||||
* @prop {Number} createdAt Timestamp of the user's creation
|
||||
* @prop {String} defaultAvatar The hash for the default avatar of a user if there is no avatar set
|
||||
* @prop {String} defaultAvatarURL The URL of the user's default avatar
|
||||
* @prop {String} discriminator The discriminator of the user
|
||||
* @prop {String} id The ID of the user
|
||||
* @prop {String} mention A string that mentions the user
|
||||
* @prop {Number?} publicFlags Publicly visible flags for this user
|
||||
* @prop {String} staticAvatarURL The URL of the user's avatar (always a JPG)
|
||||
* @prop {Boolean} system Whether the user is an official Discord system user (e.g. urgent messages)
|
||||
* @prop {String} username The username of the user
|
||||
*/
|
||||
class User extends Base {
|
||||
constructor(data, client) {
|
||||
super(data.id);
|
||||
if(!client) {
|
||||
this._missingClientError = new Error("Missing client in constructor"); // Preserve constructor callstack
|
||||
}
|
||||
this._client = client;
|
||||
this.bot = !!data.bot;
|
||||
this.system = !!data.system;
|
||||
this.update(data);
|
||||
}
|
||||
|
||||
update(data) {
|
||||
if(data.avatar !== undefined) {
|
||||
this.avatar = data.avatar;
|
||||
}
|
||||
if(data.username !== undefined) {
|
||||
this.username = data.username;
|
||||
}
|
||||
if(data.discriminator !== undefined) {
|
||||
this.discriminator = data.discriminator;
|
||||
}
|
||||
if(data.public_flags !== undefined) {
|
||||
this.publicFlags = data.public_flags;
|
||||
}
|
||||
if(data.banner !== undefined) {
|
||||
this.banner = data.banner;
|
||||
}
|
||||
if(data.accent_color !== undefined) {
|
||||
this.accentColor = data.accent_color;
|
||||
}
|
||||
}
|
||||
|
||||
get avatarURL() {
|
||||
if(this._missingClientError) {
|
||||
throw this._missingClientError;
|
||||
}
|
||||
return this.avatar ? this._client._formatImage(Endpoints.USER_AVATAR(this.id, this.avatar)) : this.defaultAvatarURL;
|
||||
}
|
||||
|
||||
get bannerURL() {
|
||||
if(!this.banner) {
|
||||
return null;
|
||||
}
|
||||
if(this._missingClientError) {
|
||||
throw this._missingClientError;
|
||||
}
|
||||
return this._client._formatImage(Endpoints.BANNER(this.id, this.banner));
|
||||
}
|
||||
|
||||
get defaultAvatar() {
|
||||
return this.discriminator % 5;
|
||||
}
|
||||
|
||||
get defaultAvatarURL() {
|
||||
return `${Endpoints.CDN_URL}${Endpoints.DEFAULT_USER_AVATAR(this.defaultAvatar)}.png`;
|
||||
}
|
||||
|
||||
get mention() {
|
||||
return `<@${this.id}>`;
|
||||
}
|
||||
|
||||
get staticAvatarURL() {
|
||||
if(this._missingClientError) {
|
||||
throw this._missingClientError;
|
||||
}
|
||||
return this.avatar ? this._client._formatImage(Endpoints.USER_AVATAR(this.id, this.avatar), "jpg") : this.defaultAvatarURL;
|
||||
}
|
||||
|
||||
/**
|
||||
* [USER ACCOUNT] Create a relationship with the user
|
||||
* @arg {Boolean} [block=false] If true, block the user. Otherwise, add the user as a friend
|
||||
* @returns {Promise}
|
||||
*/
|
||||
addRelationship(block) {
|
||||
return this._client.addRelationship.call(this._client, this.id, block);
|
||||
}
|
||||
|
||||
/**
|
||||
* [USER ACCOUNT] Delete the current user's note for another user
|
||||
*/
|
||||
deleteNote() {
|
||||
return this._client.deleteUserNote.call(this._client, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user's avatar with the given format and size
|
||||
* @arg {String} [format] The filetype of the avatar ("jpg", "jpeg", "png", "gif", or "webp")
|
||||
* @arg {Number} [size] The size of the avatar (any power of two between 16 and 4096)
|
||||
* @returns {String}
|
||||
*/
|
||||
dynamicAvatarURL(format, size) {
|
||||
if(!this.avatar) {
|
||||
return this.defaultAvatarURL;
|
||||
}
|
||||
if(this._missingClientError) {
|
||||
throw this._missingClientError;
|
||||
}
|
||||
return this._client._formatImage(Endpoints.USER_AVATAR(this.id, this.avatar), format, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user's banner with the given format and size
|
||||
* @arg {String} [format] The filetype of the banner ("jpg", "jpeg", "png", "gif", or "webp")
|
||||
* @arg {Number} [size] The size of the banner (any power of two between 16 and 4096)
|
||||
* @returns {String?}
|
||||
*/
|
||||
dynamicBannerURL(format, size) {
|
||||
if(!this.banner) {
|
||||
return null;
|
||||
}
|
||||
if(this._missingClientError) {
|
||||
throw this._missingClientError;
|
||||
}
|
||||
return this._client._formatImage(Endpoints.BANNER(this.id, this.banner), format, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* [USER ACCOUNT] Edit the current user's note for the user
|
||||
* @arg {String} note The note
|
||||
* @returns {Promise}
|
||||
*/
|
||||
editNote(note) {
|
||||
return this._client.editUserNote.call(this._client, this.id, note);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a DM channel with the user, or create one if it does not exist
|
||||
* @returns {Promise<PrivateChannel>}
|
||||
*/
|
||||
getDMChannel() {
|
||||
return this._client.getDMChannel.call(this._client, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* [USER ACCOUNT] Get profile data for the user
|
||||
* @returns {Promise<Object>} The user's profile data.
|
||||
*/
|
||||
getProfile() {
|
||||
return this._client.getUserProfile.call(this._client, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* [USER ACCOUNT] Remove a relationship with the user
|
||||
* @returns {Promise}
|
||||
*/
|
||||
removeRelationship() {
|
||||
return this._client.removeRelationship.call(this._client, this.id);
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"accentColor",
|
||||
"avatar",
|
||||
"banner",
|
||||
"bot",
|
||||
"discriminator",
|
||||
"publicFlags",
|
||||
"system",
|
||||
"username",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = User;
|
95
node_modules/eris/lib/structures/VoiceChannel.js
generated
vendored
Normal file
95
node_modules/eris/lib/structures/VoiceChannel.js
generated
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
"use strict";
|
||||
|
||||
const Collection = require("../util/Collection");
|
||||
const GuildChannel = require("./GuildChannel");
|
||||
const Member = require("./Member");
|
||||
|
||||
/**
|
||||
* Represents a guild voice channel. See GuildChannel for more properties and methods.
|
||||
* @extends GuildChannel
|
||||
* @prop {Number?} bitrate The bitrate of the channel
|
||||
* @prop {String?} rtcRegion The RTC region ID of the channel (automatic when `null`)
|
||||
* @prop {Number} type The type of the channel
|
||||
* @prop {Number?} userLimit The max number of users that can join the channel
|
||||
* @prop {Number?} videoQualityMode The camera video quality mode of the voice channel. `1` is auto, `2` is 720p
|
||||
* @prop {Collection<Member>} voiceMembers Collection of Members in this channel
|
||||
*/
|
||||
class VoiceChannel extends GuildChannel {
|
||||
constructor(data, client) {
|
||||
super(data, client);
|
||||
this.voiceMembers = new Collection(Member);
|
||||
this.update(data);
|
||||
}
|
||||
|
||||
update(data) {
|
||||
super.update(data);
|
||||
|
||||
if(data.bitrate !== undefined) {
|
||||
this.bitrate = data.bitrate;
|
||||
}
|
||||
if(data.rtc_region !== undefined) {
|
||||
this.rtcRegion = data.rtc_region;
|
||||
}
|
||||
if(data.user_limit !== undefined) {
|
||||
this.userLimit = data.user_limit;
|
||||
}
|
||||
if(data.video_quality_mode !== undefined) {
|
||||
this.videoQualityMode = data.video_quality_mode;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an invite for the channel
|
||||
* @arg {Object} [options] Invite generation options
|
||||
* @arg {Number} [options.maxAge] How long the invite should last in seconds
|
||||
* @arg {Number} [options.maxUses] How many uses the invite should last for
|
||||
* @arg {Boolean} [options.temporary] Whether the invite grants temporary membership or not
|
||||
* @arg {Boolean} [options.unique] Whether the invite is unique or not
|
||||
* @arg {String} [reason] The reason to be displayed in audit logs
|
||||
* @returns {Promise<Invite>}
|
||||
*/
|
||||
createInvite(options, reason) {
|
||||
return this.client.createChannelInvite.call(this.client, this.id, options, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all invites in the channel
|
||||
* @returns {Promise<Array<Invite>>}
|
||||
*/
|
||||
getInvites() {
|
||||
return this.client.getChannelInvites.call(this.client, this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Joins the channel.
|
||||
* @arg {Object} [options] VoiceConnection constructor options
|
||||
* @arg {Object} [options.opusOnly] Skip opus encoder initialization. You should not enable this unless you know what you are doing
|
||||
* @arg {Object} [options.shared] Whether the VoiceConnection will be part of a SharedStream or not
|
||||
* @arg {Boolean} [options.selfMute] Whether the bot joins the channel muted or not
|
||||
* @arg {Boolean} [options.selfDeaf] Whether the bot joins the channel deafened or not
|
||||
* @returns {Promise<VoiceConnection>} Resolves with a VoiceConnection
|
||||
*/
|
||||
join(options) {
|
||||
return this.client.joinVoiceChannel.call(this.client, this.id, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Leaves the channel.
|
||||
*/
|
||||
leave() {
|
||||
return this.client.leaveVoiceChannel.call(this.client, this.id);
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"bitrate",
|
||||
"rtcRegion",
|
||||
"userLimit",
|
||||
"videoQualityMode",
|
||||
"voiceMembers",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = VoiceChannel;
|
83
node_modules/eris/lib/structures/VoiceState.js
generated
vendored
Normal file
83
node_modules/eris/lib/structures/VoiceState.js
generated
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
"use strict";
|
||||
|
||||
const Base = require("./Base");
|
||||
|
||||
/**
|
||||
* Represents a member's voice state in a call/guild
|
||||
* @prop {String?} channelID The ID of the member's current voice channel
|
||||
* @prop {Boolean} deaf Whether the member is server deafened or not
|
||||
* @prop {String} id The ID of the member
|
||||
* @prop {Boolean} mute Whether the member is server muted or not
|
||||
* @prop {Number?} requestToSpeakTimestamp Timestamp of the member's latest request to speak
|
||||
* @prop {Boolean} selfDeaf Whether the member is self deafened or not
|
||||
* @prop {Boolean} selfMute Whether the member is self muted or not
|
||||
* @prop {Boolean} selfStream Whether the member is streaming using "Go Live"
|
||||
* @prop {Boolean} selfVideo Whether the member's camera is enabled
|
||||
* @prop {Boolean} suppress Whether the member is suppressed or not
|
||||
* @prop {String?} sessionID The ID of the member's current voice session
|
||||
*/
|
||||
class VoiceState extends Base {
|
||||
constructor(data) {
|
||||
super(data.id);
|
||||
this.mute = false;
|
||||
this.deaf = false;
|
||||
this.requestToSpeakTimestamp = null;
|
||||
this.selfMute = false;
|
||||
this.selfDeaf = false;
|
||||
this.selfStream = false;
|
||||
this.selfVideo = false;
|
||||
this.suppress = false;
|
||||
this.update(data);
|
||||
}
|
||||
|
||||
update(data) {
|
||||
if(data.channel_id !== undefined) {
|
||||
this.channelID = data.channel_id;
|
||||
this.sessionID = data.channel_id === null ? null : data.session_id;
|
||||
} else if(this.channelID === undefined) {
|
||||
this.channelID = this.sessionID = null;
|
||||
}
|
||||
if(data.mute !== undefined) {
|
||||
this.mute = data.mute;
|
||||
}
|
||||
if(data.deaf !== undefined) {
|
||||
this.deaf = data.deaf;
|
||||
}
|
||||
if(data.request_to_speak_timestamp !== undefined) {
|
||||
this.requestToSpeakTimestamp = Date.parse(data.request_to_speak_timestamp);
|
||||
}
|
||||
if(data.self_mute !== undefined) {
|
||||
this.selfMute = data.self_mute;
|
||||
}
|
||||
if(data.self_deaf !== undefined) {
|
||||
this.selfDeaf = data.self_deaf;
|
||||
}
|
||||
if(data.self_video !== undefined) {
|
||||
this.selfVideo = data.self_video;
|
||||
}
|
||||
if(data.self_stream !== undefined) {
|
||||
this.selfStream = data.self_stream;
|
||||
}
|
||||
if(data.suppress !== undefined) { // Bots ignore this
|
||||
this.suppress = data.suppress;
|
||||
}
|
||||
}
|
||||
|
||||
toJSON(props = []) {
|
||||
return super.toJSON([
|
||||
"channelID",
|
||||
"deaf",
|
||||
"mute",
|
||||
"requestToSpeakTimestamp",
|
||||
"selfDeaf",
|
||||
"selfMute",
|
||||
"selfStream",
|
||||
"selfVideo",
|
||||
"sessionID",
|
||||
"suppress",
|
||||
...props
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = VoiceState;
|
Reference in New Issue
Block a user