Emoji steal command.

i hate coding and trying to find code that does work i litrally have tears anyways @ShompiFlen
26 Replies
d.js toolkit
d.js toolkit9mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
ShompiFlen
ShompiFlen9mo ago
okay wait because i said i would help you code one but if you are not willing to then im not gonna help
M
MOP9mo ago
yay i can send you what i have, it no workey
ShompiFlen
ShompiFlen9mo ago
sure
M
MOP9mo ago
if i fix one error i run into another and another and another and another and another ect ect
} else if (command === 'emojisteal') {
if (!message.member.permissions.has('ManageEmojisAndStickers') &&
message.author.id !== process.env.OWNER_ID) {
return message.channel.send("You don't have permission to use this command.");
}

const [emojiArg] = args;
if (!emojiArg || !emojiArg.match(/^<a?:\w+:\d+>$/)) {
return message.reply('Please provide a valid emoji.');
}

const [, emojiName, emojiId] = emojiArg.match(/<a?:\w+:(\d+)>/);
const emojiURL = `https://cdn.discordapp.com/emojis/${emojiId}`;

try {
const emoji = await message.guild.emojis.create(emojiURL, emojiName);
message.reply(`Emoji ${emoji} has been added to the guild.`);
} catch (error) {
console.error('Error adding emoji to the guild:', error);
message.reply('An error occurred while adding the emoji to the guild.');
}
} else if (command === 'emojisteal') {
if (!message.member.permissions.has('ManageEmojisAndStickers') &&
message.author.id !== process.env.OWNER_ID) {
return message.channel.send("You don't have permission to use this command.");
}

const [emojiArg] = args;
if (!emojiArg || !emojiArg.match(/^<a?:\w+:\d+>$/)) {
return message.reply('Please provide a valid emoji.');
}

const [, emojiName, emojiId] = emojiArg.match(/<a?:\w+:(\d+)>/);
const emojiURL = `https://cdn.discordapp.com/emojis/${emojiId}`;

try {
const emoji = await message.guild.emojis.create(emojiURL, emojiName);
message.reply(`Emoji ${emoji} has been added to the guild.`);
} catch (error) {
console.error('Error adding emoji to the guild:', error);
message.reply('An error occurred while adding the emoji to the guild.');
}
ShompiFlen
ShompiFlen9mo ago
okay... so where does this fail what happens when you try to use it
M
MOP9mo ago
i think it needs to be converted to base64 due to the emoji add api
Error adding emoji to the guild: TypeError [ReqResourceType]: The resource must be a string, Buffer or a valid file stream.
at GuildEmojiManager.create (C:\Users\Minoa\node_modules\discord.js\src\managers\GuildEmojiManager.js:54:28)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Client.<anonymous> (C:\Users\Minoa\Desktop\bot\index.js:2911:23) {
code: 'ReqResourceType'
}
Error adding emoji to the guild: TypeError [ReqResourceType]: The resource must be a string, Buffer or a valid file stream.
at GuildEmojiManager.create (C:\Users\Minoa\node_modules\discord.js\src\managers\GuildEmojiManager.js:54:28)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Client.<anonymous> (C:\Users\Minoa\Desktop\bot\index.js:2911:23) {
code: 'ReqResourceType'
}
ShompiFlen
ShompiFlen9mo ago
what version of discord.js are you using on this project? take a look at package.json
M
MOP9mo ago
14.14.4 i think
M
MOP9mo ago
i just noticed my package and package lock is missing im confused
ShompiFlen
ShompiFlen9mo ago
you dont have a package.json in your project folder?
M
MOP9mo ago
i did idk what happend
ShompiFlen
ShompiFlen9mo ago
might have to install dependencies again if you can't recover that
M
MOP9mo ago
its wtv i have a backup on github ill get later
ShompiFlen
ShompiFlen9mo ago
npm init then npm install discord.js that would be if you didn't install any other dependencies alright change this for the correct syntax .emojis.create({attachment: urlToEmoji, name: emojiName})
M
MOP9mo ago
i just did that lol
M
MOP9mo ago
Minoa
✿ ☆:.。. o(≧▽≦)o .。.:☆ ✿
lov u
ShompiFlen
ShompiFlen9mo ago
alright, can you try running the command now and see what happens if it creates the emoji in the guild or not
M
MOP9mo ago
i forgor to define the guild whol up
M
MOP9mo ago
kinda works but the name is messed up https://thicc-thighs.com/g8t073df.png
Minoa
✿ ☆:.。. o(≧▽≦)o .。.:☆ ✿
lov u
ShompiFlen
ShompiFlen9mo ago
you need to clean up the name the name contains invalid characters for an emoji name you can use this https://discord.js.org/docs/packages/discord.js/main/parseEmoji:Function
M
MOP9mo ago
im fixxing it rn
ShompiFlen
ShompiFlen9mo ago
its a function you can import from discord.js and probably pass in your emojiArg, not sure what that is it should return a PartialEmoji which has a name, id, and a whether or not its animated, you can then just use the name of it and pass it to the create call https://discord.js.org/docs/packages/discord.js/main/PartialEmoji:Interface actually just pass the emojiName variable to parseEmoji and then use the result of that to get the name
M
MOP9mo ago
omfg i finnally got it yay
ShompiFlen
ShompiFlen9mo ago
nice :Alfanod: feel free to resolve this post if you dont have any further questions :deusVult:
Want results from more Discord servers?
Add your server