-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathsteal.js
More file actions
115 lines (107 loc) · 3.45 KB
/
steal.js
File metadata and controls
115 lines (107 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
const { EmbedBuilder, ApplicationCommandOptionType } = require("discord.js");
module.exports = {
name: "steal",
description: "Steal emojis or stickers from other servers",
category: "ADMIN",
command: {
enabled: true,
usage: "COMMAND",
minArgsCount: 2,
subcommands: [
{
trigger: "emoji <emoji> <name>",
description: "Steal an emoji from another server",
},
{
trigger: "sticker <url> <name>",
description: "Steal a sticker from another server",
},
],
},
slashCommand: {
enabled: true,
options: [
{
name: "emoji",
description: "Steal an emoji from another server",
type: ApplicationCommandOptionType.Subcommand,
options: [
{
name: "emoji",
description: "The emoji to steal",
type: ApplicationCommandOptionType.String,
required: true,
},
{
name: "name",
description: "Name for the new emoji",
type: ApplicationCommandOptionType.String,
required: true,
},
],
},
{
name: "sticker",
description: "Steal a sticker from another server",
type: ApplicationCommandOptionType.Subcommand,
options: [
{
name: "url",
description: "URL of the sticker to steal",
type: ApplicationCommandOptionType.String,
required: true,
},
{
name: "name",
description: "Name for the new sticker",
type: ApplicationCommandOptionType.String,
required: true,
},
],
},
],
},
async messageRun(message, args) {
const subcommand = args.shift();
const response = await handleSteal(subcommand, args, message.guild);
await message.safeReply(response);
},
async interactionRun(interaction) {
const subcommand = interaction.options.getSubcommand();
const response = await handleSteal(subcommand, interaction.options, interaction.guild);
await interaction.followUp(response);
},
};
async function handleSteal(subcommand, options, guild) {
let embed;
if (subcommand === "emoji") {
const emoji = options.getString ? options.getString("emoji") : options.shift();
const name = options.getString ? options.getString("name") : options.join(" ");
const emojiId = emoji.match(/\d+/)[0];
const emojiURL = `https://cdn.discordapp.com/emojis/${emojiId}.png`;
try {
await guild.emojis.create({ attachment: emojiURL, name });
embed = new EmbedBuilder()
.setColor("Green")
.setDescription(`Emoji **${name}** has been added successfully!`);
} catch {
embed = new EmbedBuilder()
.setColor("Red")
.setDescription("Unable to add emoji. Please check if the emoji source is valid.");
}
} else if (subcommand === "sticker") {
const url = options.getString ? options.getString("url") : options.shift();
const name = options.getString ? options.getString("name") : options.join(" ");
try {
await guild.stickers.create({ file: url, name });
embed = new EmbedBuilder()
.setColor("Green")
.setDescription(`Sticker **${name}** has been added successfully!`);
} catch {
embed = new EmbedBuilder()
.setColor("Red")
.setDescription("Unable to add sticker. Please verify that the URL is correct.");
}
}
return { embeds: [embed] };
}