summaryrefslogtreecommitdiff
path: root/node_modules/discord.js/src/structures/interfaces/Application.js
diff options
context:
space:
mode:
authorsowgro <tpoke.ferrari@gmail.com>2023-09-02 19:12:47 -0400
committersowgro <tpoke.ferrari@gmail.com>2023-09-02 19:12:47 -0400
commite4450c8417624b71d779cb4f41692538f9165e10 (patch)
treeb70826542223ecdf8a7a259f61b0a1abb8a217d8 /node_modules/discord.js/src/structures/interfaces/Application.js
downloadsowbot3-e4450c8417624b71d779cb4f41692538f9165e10.tar.gz
sowbot3-e4450c8417624b71d779cb4f41692538f9165e10.tar.bz2
sowbot3-e4450c8417624b71d779cb4f41692538f9165e10.zip
first commit
Diffstat (limited to 'node_modules/discord.js/src/structures/interfaces/Application.js')
-rw-r--r--node_modules/discord.js/src/structures/interfaces/Application.js108
1 files changed, 108 insertions, 0 deletions
diff --git a/node_modules/discord.js/src/structures/interfaces/Application.js b/node_modules/discord.js/src/structures/interfaces/Application.js
new file mode 100644
index 0000000..5e81465
--- /dev/null
+++ b/node_modules/discord.js/src/structures/interfaces/Application.js
@@ -0,0 +1,108 @@
+'use strict';
+
+const { DiscordSnowflake } = require('@sapphire/snowflake');
+const Base = require('../Base');
+
+/**
+ * Represents an OAuth2 Application.
+ * @extends {Base}
+ * @abstract
+ */
+class Application extends Base {
+ constructor(client, data) {
+ super(client);
+ this._patch(data);
+ }
+
+ _patch(data) {
+ /**
+ * The application's id
+ * @type {Snowflake}
+ */
+ this.id = data.id;
+
+ if ('name' in data) {
+ /**
+ * The name of the application
+ * @type {?string}
+ */
+ this.name = data.name;
+ } else {
+ this.name ??= null;
+ }
+
+ if ('description' in data) {
+ /**
+ * The application's description
+ * @type {?string}
+ */
+ this.description = data.description;
+ } else {
+ this.description ??= null;
+ }
+
+ if ('icon' in data) {
+ /**
+ * The application's icon hash
+ * @type {?string}
+ */
+ this.icon = data.icon;
+ } else {
+ this.icon ??= null;
+ }
+ }
+
+ /**
+ * The timestamp the application was created at
+ * @type {number}
+ * @readonly
+ */
+ get createdTimestamp() {
+ return DiscordSnowflake.timestampFrom(this.id);
+ }
+
+ /**
+ * The time the application was created at
+ * @type {Date}
+ * @readonly
+ */
+ get createdAt() {
+ return new Date(this.createdTimestamp);
+ }
+
+ /**
+ * A link to the application's icon.
+ * @param {ImageURLOptions} [options={}] Options for the image URL
+ * @returns {?string}
+ */
+ iconURL(options = {}) {
+ return this.icon && this.client.rest.cdn.appIcon(this.id, this.icon, options);
+ }
+
+ /**
+ * A link to this application's cover image.
+ * @param {ImageURLOptions} [options={}] Options for the image URL
+ * @returns {?string}
+ */
+ coverURL(options = {}) {
+ return this.cover && this.client.rest.cdn.appIcon(this.id, this.cover, options);
+ }
+
+ /**
+ * When concatenated with a string, this automatically returns the application's name instead of the
+ * Application object.
+ * @returns {?string}
+ * @example
+ * // Logs: Application name: My App
+ * console.log(`Application name: ${application}`);
+ */
+ toString() {
+ return this.name;
+ }
+
+ toJSON() {
+ return super.toJSON({ createdTimestamp: true });
+ }
+}
+
+module.exports = Application;