@fjrodafo/discord-app 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CONTRIBUTING ADDED
@@ -0,0 +1,9 @@
1
+ Feel free to contribute to this repository!
2
+
3
+ If you spot a problem with the docs, search if an issue already exists at https://github.com/FJrodafo/DiscordAPP/issues. If a related issue doesn't exist, you can open a new issue using a relevant issue form.
4
+
5
+ If you find an issue to work on, you are welcome to open a pull/merge request with a fix at https://github.com/FJrodafo/DiscordAPP/pulls. To work on the pull request, fork the repository at https://github.com/FJrodafo/DiscordAPP/forks.
6
+
7
+ Please do not copy questions and answers from other sources, they probably worked hard to add them, and if you add new images, make sure they are free and usable.
8
+
9
+ Thank you very much for the contribution!
package/LICENSE ADDED
@@ -0,0 +1,121 @@
1
+ Creative Commons Legal Code
2
+
3
+ CC0 1.0 Universal
4
+
5
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
+ HEREUNDER.
13
+
14
+ Statement of Purpose
15
+
16
+ The laws of most jurisdictions throughout the world automatically confer
17
+ exclusive Copyright and Related Rights (defined below) upon the creator
18
+ and subsequent owner(s) (each and all, an "owner") of an original work of
19
+ authorship and/or a database (each, a "Work").
20
+
21
+ Certain owners wish to permanently relinquish those rights to a Work for
22
+ the purpose of contributing to a commons of creative, cultural and
23
+ scientific works ("Commons") that the public can reliably and without fear
24
+ of later claims of infringement build upon, modify, incorporate in other
25
+ works, reuse and redistribute as freely as possible in any form whatsoever
26
+ and for any purposes, including without limitation commercial purposes.
27
+ These owners may contribute to the Commons to promote the ideal of a free
28
+ culture and the further production of creative, cultural and scientific
29
+ works, or to gain reputation or greater distribution for their Work in
30
+ part through the use and efforts of others.
31
+
32
+ For these and/or other purposes and motivations, and without any
33
+ expectation of additional consideration or compensation, the person
34
+ associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
+ is an owner of Copyright and Related Rights in the Work, voluntarily
36
+ elects to apply CC0 to the Work and publicly distribute the Work under its
37
+ terms, with knowledge of his or her Copyright and Related Rights in the
38
+ Work and the meaning and intended legal effect of CC0 on those rights.
39
+
40
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
41
+ protected by copyright and related or neighboring rights ("Copyright and
42
+ Related Rights"). Copyright and Related Rights include, but are not
43
+ limited to, the following:
44
+
45
+ i. the right to reproduce, adapt, distribute, perform, display,
46
+ communicate, and translate a Work;
47
+ ii. moral rights retained by the original author(s) and/or performer(s);
48
+ iii. publicity and privacy rights pertaining to a person's image or
49
+ likeness depicted in a Work;
50
+ iv. rights protecting against unfair competition in regards to a Work,
51
+ subject to the limitations in paragraph 4(a), below;
52
+ v. rights protecting the extraction, dissemination, use and reuse of data
53
+ in a Work;
54
+ vi. database rights (such as those arising under Directive 96/9/EC of the
55
+ European Parliament and of the Council of 11 March 1996 on the legal
56
+ protection of databases, and under any national implementation
57
+ thereof, including any amended or successor version of such
58
+ directive); and
59
+ vii. other similar, equivalent or corresponding rights throughout the
60
+ world based on applicable law or treaty, and any national
61
+ implementations thereof.
62
+
63
+ 2. Waiver. To the greatest extent permitted by, but not in contravention
64
+ of, applicable law, Affirmer hereby overtly, fully, permanently,
65
+ irrevocably and unconditionally waives, abandons, and surrenders all of
66
+ Affirmer's Copyright and Related Rights and associated claims and causes
67
+ of action, whether now known or unknown (including existing as well as
68
+ future claims and causes of action), in the Work (i) in all territories
69
+ worldwide, (ii) for the maximum duration provided by applicable law or
70
+ treaty (including future time extensions), (iii) in any current or future
71
+ medium and for any number of copies, and (iv) for any purpose whatsoever,
72
+ including without limitation commercial, advertising or promotional
73
+ purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
+ member of the public at large and to the detriment of Affirmer's heirs and
75
+ successors, fully intending that such Waiver shall not be subject to
76
+ revocation, rescission, cancellation, termination, or any other legal or
77
+ equitable action to disrupt the quiet enjoyment of the Work by the public
78
+ as contemplated by Affirmer's express Statement of Purpose.
79
+
80
+ 3. Public License Fallback. Should any part of the Waiver for any reason
81
+ be judged legally invalid or ineffective under applicable law, then the
82
+ Waiver shall be preserved to the maximum extent permitted taking into
83
+ account Affirmer's express Statement of Purpose. In addition, to the
84
+ extent the Waiver is so judged Affirmer hereby grants to each affected
85
+ person a royalty-free, non transferable, non sublicensable, non exclusive,
86
+ irrevocable and unconditional license to exercise Affirmer's Copyright and
87
+ Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
+ maximum duration provided by applicable law or treaty (including future
89
+ time extensions), (iii) in any current or future medium and for any number
90
+ of copies, and (iv) for any purpose whatsoever, including without
91
+ limitation commercial, advertising or promotional purposes (the
92
+ "License"). The License shall be deemed effective as of the date CC0 was
93
+ applied by Affirmer to the Work. Should any part of the License for any
94
+ reason be judged legally invalid or ineffective under applicable law, such
95
+ partial invalidity or ineffectiveness shall not invalidate the remainder
96
+ of the License, and in such case Affirmer hereby affirms that he or she
97
+ will not (i) exercise any of his or her remaining Copyright and Related
98
+ Rights in the Work or (ii) assert any associated claims and causes of
99
+ action with respect to the Work, in either case contrary to Affirmer's
100
+ express Statement of Purpose.
101
+
102
+ 4. Limitations and Disclaimers.
103
+
104
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
+ surrendered, licensed or otherwise affected by this document.
106
+ b. Affirmer offers the Work as-is and makes no representations or
107
+ warranties of any kind concerning the Work, express, implied,
108
+ statutory or otherwise, including without limitation warranties of
109
+ title, merchantability, fitness for a particular purpose, non
110
+ infringement, or the absence of latent or other defects, accuracy, or
111
+ the present or absence of errors, whether or not discoverable, all to
112
+ the greatest extent permissible under applicable law.
113
+ c. Affirmer disclaims responsibility for clearing rights of other persons
114
+ that may apply to the Work or any use thereof, including without
115
+ limitation any person's Copyright and Related Rights in the Work.
116
+ Further, Affirmer disclaims responsibility for obtaining any necessary
117
+ consents, permissions or other rights required for any use of the
118
+ Work.
119
+ d. Affirmer understands and acknowledges that Creative Commons is not a
120
+ party to this document and has no duty or obligation with respect to
121
+ this CC0 or use of the Work.
@@ -0,0 +1,27 @@
1
+ const express = require('express');
2
+ const http = require('node:http');
3
+ const path = require('node:path');
4
+ const { findAvailablePort } = require('@fjrodafo/port-finder');
5
+
6
+ module.exports = (client) => {
7
+ const app = express();
8
+ const server = http.createServer(app);
9
+ const apiRoutes = require('./routes/api.js')(client);
10
+ const logsRoutes = require('./routes/logs.js')();
11
+ const metricsRoute = require('./routes/metrics.js')(client);
12
+ const desiredPort = process.env.PORT ?? 3000;
13
+
14
+ app.use(express.static(path.join(__dirname, 'public')));
15
+
16
+ app.use('/api', apiRoutes);
17
+ app.use('/logs', logsRoutes);
18
+ app.use('/metrics', metricsRoute);
19
+
20
+ findAvailablePort(desiredPort).then(port => {
21
+ server.listen(port, () => {
22
+ console.log(`Dashboard --> http://localhost:${port}`);
23
+ });
24
+ }).catch(err => {
25
+ console.error('Error searching for available port:', err);
26
+ });
27
+ };
@@ -0,0 +1,18 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <title>DiscordAPP | Dashboard</title>
7
+ <link rel="stylesheet" href="style.css">
8
+ </head>
9
+
10
+ <body>
11
+ <h2>DiscordAPP | Dashboard</h2>
12
+ <button id="apiBtn">API</button>
13
+ <button id="logsBtn">Logs</button>
14
+ <button id="metricsBtn">Metrics</button>
15
+ <script src="script.js"></script>
16
+ </body>
17
+
18
+ </html>
@@ -0,0 +1,11 @@
1
+ document.getElementById('apiBtn').addEventListener('click', () => {
2
+ window.open('/api', '_blank');
3
+ });
4
+
5
+ document.getElementById('logsBtn').addEventListener('click', () => {
6
+ window.open('/logs', '_blank');
7
+ });
8
+
9
+ document.getElementById('metricsBtn').addEventListener('click', () => {
10
+ window.open('/metrics', '_blank');
11
+ });
File without changes
@@ -0,0 +1,75 @@
1
+ const express = require('express');
2
+ const router = express.Router();
3
+ const { formatAge, formatTime, formatMemory, formatCPU } = require('./../utils/format.js');
4
+
5
+ module.exports = (client) => {
6
+ router.get('/', (_, res) => {
7
+ try {
8
+ res.json({
9
+ app: {
10
+ id: client.user.id,
11
+ username: client.user.username,
12
+ tag: client.user.tag,
13
+ discriminator: client.user.discriminator,
14
+ avatarURL: {
15
+ webp: client.user.displayAvatarURL({ dynamic: true }),
16
+ png: client.user.displayAvatarURL({ dynamic: true }).replace('webp', 'png'),
17
+ },
18
+ createdAt: client.user.createdAt,
19
+ createdTimestamp: formatAge(client.user.createdTimestamp),
20
+ },
21
+ status: {
22
+ online: client.isReady(),
23
+ status: client.isReady() ? 'Online' : 'Offline',
24
+ presence: client.user.presence?.status ?? 'unknown',
25
+ activity: client.user.presence?.activities[0]?.name ?? 'None',
26
+ activityType: client.user.presence?.activities[0]?.type ?? 'None',
27
+ readyTimestamp: formatTime(Math.floor((Date.now() - client.readyTimestamp) / 1000)),
28
+ ping: client.ws.ping,
29
+ },
30
+ commands: {
31
+ total: client.commands.size,
32
+ commandsList: Array.from(client.commands.keys()),
33
+ cooldowns: client.cooldowns.size,
34
+ events: client.eventNames().length,
35
+ eventsList: client.eventNames(),
36
+ },
37
+ guilds: {
38
+ total: client.guilds.cache.size,
39
+ guildUsers: client.guilds.cache.reduce((acc, g) => acc + g.memberCount, 0),
40
+ averageMembers: Math.round(client.guilds.cache.reduce((acc, g) => acc + g.memberCount, 0) / client.guilds.cache.size),
41
+ largestGuild: client.guilds.cache.sort((a, b) => b.memberCount - a.memberCount).first()?.name ?? 'N/A',
42
+ smallestGuild: client.guilds.cache.sort((a, b) => a.memberCount - b.memberCount).first()?.name ?? 'N/A',
43
+ guildsDetails: client.guilds.cache.map(g => ({
44
+ id: g.id,
45
+ name: g.name,
46
+ members: g.memberCount,
47
+ channels: g.channels.cache.size,
48
+ bots: g.members.cache.filter(m => m.user.bot).size,
49
+ })),
50
+ },
51
+ cache: {
52
+ cachedUsers: client.users.cache.size,
53
+ cachedChannels: client.channels.cache.size,
54
+ cachedRoles: client.guilds.cache.reduce((acc, g) => acc + g.roles.cache.size, 0),
55
+ cachedEmojis: client.guilds.cache.reduce((acc, g) => acc + g.emojis.cache.size, 0),
56
+ },
57
+ system: {
58
+ uptime: formatTime(Math.floor(process.uptime())),
59
+ memory: formatMemory(),
60
+ cpu: formatCPU(),
61
+ pid: process.pid,
62
+ version: process.version,
63
+ platform: process.platform,
64
+ arch: process.arch,
65
+ },
66
+ });
67
+ }
68
+ catch (err) {
69
+ console.error('Error generating API response:', err);
70
+ res.status(500).json({ error: 'Internal Server Error' });
71
+ }
72
+ });
73
+
74
+ return router;
75
+ };
@@ -0,0 +1,11 @@
1
+ const express = require('express');
2
+ const router = express.Router();
3
+ const logs = require('./../utils/logs.js');
4
+
5
+ module.exports = () => {
6
+ router.get('/', (_, res) => {
7
+ res.json(logs.getAll());
8
+ });
9
+
10
+ return router;
11
+ };
@@ -0,0 +1,57 @@
1
+ const express = require('express');
2
+ const router = express.Router();
3
+
4
+ module.exports = (client) => {
5
+ router.get('/', (_, res) => {
6
+ const mem = process.memoryUsage();
7
+ const cpu = process.cpuUsage();
8
+ const uptime = Math.floor(process.uptime());
9
+ const guilds = client.guilds?.cache?.size ?? 0;
10
+ const users = client.users?.cache?.size ?? 0;
11
+
12
+ res.set('Content-Type', 'text/plain');
13
+ res.send(`
14
+ # HELP discord_bot_up Is the bot online
15
+ # TYPE discord_bot_up gauge
16
+ discord_bot_up ${client.isReady() ? 1 : 0}
17
+
18
+ # HELP discord_bot_ping Websocket ping
19
+ # TYPE discord_bot_ping gauge
20
+ discord_bot_ping ${client.ws?.ping ?? 0}
21
+
22
+ # HELP process_uptime_seconds Process uptime
23
+ # TYPE process_uptime_seconds gauge
24
+ process_uptime_seconds ${uptime}
25
+
26
+ # HELP process_cpu_user_microseconds_total CPU user time
27
+ # TYPE process_cpu_user_microseconds_total counter
28
+ process_cpu_user_microseconds_total ${cpu.user}
29
+
30
+ # HELP process_cpu_system_microseconds_total CPU system time
31
+ # TYPE process_cpu_system_microseconds_total counter
32
+ process_cpu_system_microseconds_total ${cpu.system}
33
+
34
+ # HELP process_memory_rss_bytes Resident Set Size
35
+ # TYPE process_memory_rss_bytes gauge
36
+ process_memory_rss_bytes ${mem.rss}
37
+
38
+ # HELP process_memory_heap_used_bytes Heap used
39
+ # TYPE process_memory_heap_used_bytes gauge
40
+ process_memory_heap_used_bytes ${mem.heapUsed}
41
+
42
+ # HELP process_memory_heap_total_bytes Heap total
43
+ # TYPE process_memory_heap_total_bytes gauge
44
+ process_memory_heap_total_bytes ${mem.heapTotal}
45
+
46
+ # HELP discord_guilds_total Total guilds
47
+ # TYPE discord_guilds_total gauge
48
+ discord_guilds_total ${guilds}
49
+
50
+ # HELP discord_users_cached Cached users
51
+ # TYPE discord_users_cached gauge
52
+ discord_users_cached ${users}
53
+ `.trim());
54
+ });
55
+
56
+ return router;
57
+ };
@@ -0,0 +1,60 @@
1
+ function formatAge(timestampMs) {
2
+ const total = Math.floor((Date.now() - timestampMs) / 1000 / 86400);
3
+
4
+ const y = Math.floor(total / 365);
5
+ const m = Math.floor((total % 365) / 30);
6
+ const d = (total % 365) % 30;
7
+
8
+ return `${y}y ${m}m ${d}d`;
9
+ }
10
+
11
+ function formatTime(seconds) {
12
+ const h = Math.floor(seconds / 3600);
13
+ const m = Math.floor((seconds % 3600) / 60);
14
+ const s = Math.floor(seconds % 60);
15
+
16
+ return `${h}h ${m}m ${s}s`;
17
+ }
18
+
19
+ function formatMemory() {
20
+ const mem = process.memoryUsage();
21
+
22
+ const toMB = v => Math.round(v / 1024 / 1024);
23
+
24
+ return {
25
+ rss: `${toMB(mem.rss)} MB`,
26
+ heapUsed: `${toMB(mem.heapUsed)} MB`,
27
+ heapTotal: `${toMB(mem.heapTotal)} MB`,
28
+ external: `${toMB(mem.external)} MB`,
29
+ usagePercent: `${Math.round((mem.heapUsed / mem.heapTotal) * 100)}%`,
30
+ };
31
+ }
32
+
33
+ let lastCPU = process.cpuUsage();
34
+ let lastTime = Date.now();
35
+
36
+ function formatCPU() {
37
+ const now = Date.now();
38
+ const usage = process.cpuUsage(lastCPU);
39
+
40
+ const elapsedMs = now - lastTime;
41
+ const elapsedMicros = elapsedMs * 1000;
42
+
43
+ const percent = ((usage.user + usage.system) / elapsedMicros) * 100;
44
+
45
+ lastCPU = process.cpuUsage();
46
+ lastTime = now;
47
+
48
+ return {
49
+ percent: `${percent.toFixed(2)}%`,
50
+ user: `${(usage.user / 1000).toFixed(2)} ms`,
51
+ system: `${(usage.system / 1000).toFixed(2)} ms`,
52
+ };
53
+ }
54
+
55
+ module.exports = {
56
+ formatAge,
57
+ formatTime,
58
+ formatMemory,
59
+ formatCPU,
60
+ };
@@ -0,0 +1,19 @@
1
+ const logs = [];
2
+
3
+ /**
4
+ * Adds a log to the array and prints it to the console
5
+ * @param {string} message
6
+ */
7
+ function add(message) {
8
+ const timestamp = new Date().toISOString();
9
+ const entry = `[${timestamp}] ${message}`;
10
+ logs.push(entry);
11
+
12
+ if (logs.length > 2000) logs.shift();
13
+
14
+ console.log(entry);
15
+ }
16
+
17
+ function getAll() { return logs; }
18
+
19
+ module.exports = { add, getAll };
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@fjrodafo/discord-app",
3
+ "version": "1.0.0",
4
+ "description": "A simple Discord Application made in JavaScript!",
5
+ "keywords": [
6
+ "discord",
7
+ "app",
8
+ "npmjs",
9
+ "nodejs",
10
+ "discordjs",
11
+ "javascript",
12
+ "fjrodafo"
13
+ ],
14
+ "homepage": "https://github.com/FJrodafo/DiscordAPP#readme",
15
+ "bugs": {
16
+ "url": "https://github.com/FJrodafo/DiscordAPP/issues"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/FJrodafo/DiscordAPP.git"
21
+ },
22
+ "license": "CC0-1.0",
23
+ "author": "FJrodafo - Francisco José Rodríguez Afonso",
24
+ "type": "commonjs",
25
+ "main": "index.js",
26
+ "scripts": {
27
+ "start": "node ./src/deploy-commands.js && node ./src/index.js",
28
+ "canary": "node ./canary/deploy-commands.js && node ./canary/index.js",
29
+ "eslint": "eslint './**/*.js'",
30
+ "eslintfix": "eslint './**/*.js' --fix",
31
+ "test": "echo \"Error: no test specified\" && exit 1",
32
+ "tarball": "npm pack --dry-run",
33
+ "publish:npm": "npm publish --access=public --registry=https://registry.npmjs.org/",
34
+ "publish:github": "npm publish --registry=https://npm.pkg.github.com/"
35
+ },
36
+ "dependencies": {
37
+ "@fjrodafo/port-finder": "^2.0.5",
38
+ "canvas": "^3.2.0",
39
+ "discord.js": "^14.26.2",
40
+ "express": "^5.2.1",
41
+ "undici": "^7.16.0"
42
+ },
43
+ "devDependencies": {
44
+ "eslint": "^9.35.0"
45
+ }
46
+ }
@@ -0,0 +1,13 @@
1
+ const { SlashCommandBuilder } = require('discord.js');
2
+
3
+ module.exports = {
4
+ category: 'admin',
5
+ cooldown: 60,
6
+ data: new SlashCommandBuilder()
7
+ .setName('ping')
8
+ .setDescription('Replies with Pong!')
9
+ .setDefaultMemberPermissions(0),
10
+ async execute(interaction) {
11
+ await interaction.reply({ content: 'pong', ephemeral: true });
12
+ },
13
+ };
@@ -0,0 +1,36 @@
1
+ const {
2
+ SlashCommandBuilder,
3
+ PermissionFlagsBits,
4
+ } = require('discord.js');
5
+
6
+ module.exports = {
7
+ category: 'admin',
8
+ data: new SlashCommandBuilder()
9
+ .setName('prune')
10
+ .setDescription('Prune up to 99 messages!')
11
+ .setDefaultMemberPermissions(0)
12
+ .setDMPermission(false)
13
+ .addIntegerOption(option => option
14
+ .setName('amount')
15
+ .setDescription('Number of messages to prune!')
16
+ .setRequired(false),
17
+ ),
18
+ async execute(interaction) {
19
+ const amount = interaction.options.getInteger('amount');
20
+
21
+ if (!interaction.guild.members.me.permissions.has(PermissionFlagsBits.ManageMessages)) {
22
+ return interaction.reply({ content: 'I do not have permission to prune messages in this channel.', ephemeral: true });
23
+ }
24
+
25
+ if (amount < 1 || amount > 99) {
26
+ return interaction.reply({ content: 'You need to input a number between `1` and `99`', ephemeral: true });
27
+ }
28
+
29
+ await interaction.channel.bulkDelete(amount, true).catch(error => {
30
+ console.error(error);
31
+ interaction.reply({ content: 'There was an error trying to prune messages in this channel.', ephemeral: true });
32
+ });
33
+
34
+ return interaction.reply({ content: `Successfully pruned \`${amount}\` messages!`, ephemeral: true });
35
+ },
36
+ };
@@ -0,0 +1,36 @@
1
+ const { SlashCommandBuilder } = require('discord.js');
2
+
3
+ module.exports = {
4
+ category: 'admin',
5
+ data: new SlashCommandBuilder()
6
+ .setName('reload')
7
+ .setDescription('Reloads a command!')
8
+ .setDefaultMemberPermissions(0)
9
+ .setDMPermission(false)
10
+ .addStringOption(option => option
11
+ .setName('command')
12
+ .setDescription('The command to reload!')
13
+ .setRequired(true),
14
+ ),
15
+ async execute(interaction) {
16
+ const commandName = interaction.options.getString('command', true).toLowerCase();
17
+ const command = interaction.client.commands.get(commandName);
18
+
19
+ if (!command) {
20
+ return interaction.reply({ content: `There is no command with name \`/${commandName}\``, ephemeral: true });
21
+ }
22
+
23
+ delete require.cache[require.resolve(`./../${command.category}/${command.data.name}.js`)];
24
+
25
+ try {
26
+ interaction.client.commands.delete(command.data.name);
27
+ const newCommand = require(`./../${command.category}/${command.data.name}.js`);
28
+ interaction.client.commands.set(newCommand.data.name, newCommand);
29
+ await interaction.reply({ content: `Command \`/${newCommand.data.name}\` was reloaded!`, ephemeral: true });
30
+ }
31
+ catch (error) {
32
+ console.error(error);
33
+ await interaction.reply({ content: `There was an error while reloading a command \`/${command.data.name}\`:\n\`${error.message}\``, ephemeral: true });
34
+ }
35
+ },
36
+ };
@@ -0,0 +1,19 @@
1
+ const {
2
+ ContextMenuCommandBuilder,
3
+ ApplicationCommandType,
4
+ } = require('discord.js');
5
+
6
+ module.exports = {
7
+ category: 'context-menu',
8
+ data: new ContextMenuCommandBuilder()
9
+ .setName('Avatar')
10
+ .setType(ApplicationCommandType.User),
11
+ async execute(interaction) {
12
+ const userName = interaction.targetUser.username;
13
+ const userAvatar = interaction.targetUser
14
+ .displayAvatarURL({ dynamic: true })
15
+ .replace('webp', 'png');
16
+
17
+ await interaction.reply({ content: `[${userName}](${userAvatar})`, ephemeral: true });
18
+ },
19
+ };
@@ -0,0 +1,26 @@
1
+ const {
2
+ ContextMenuCommandBuilder,
3
+ ApplicationCommandType,
4
+ EmbedBuilder,
5
+ } = require('discord.js');
6
+
7
+ module.exports = {
8
+ category: 'context-menu',
9
+ data: new ContextMenuCommandBuilder()
10
+ .setName('User')
11
+ .setType(ApplicationCommandType.User)
12
+ .setDMPermission(false),
13
+ async execute(interaction) {
14
+ const user = interaction.targetUser;
15
+ const member = interaction.targetMember;
16
+ const embed = new EmbedBuilder()
17
+ .setThumbnail(`${user.displayAvatarURL()}`)
18
+ .addFields(
19
+ { name: 'User:', value: `${user.username}`, inline: true },
20
+ { name: 'ID:', value: `${user.id}`, inline: true },
21
+ { name: 'Joined at:', value: `${member.joinedAt}`, inline: false },
22
+ );
23
+
24
+ return interaction.reply({ embeds: [embed], ephemeral: true });
25
+ },
26
+ };