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 toolkit2y 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
ShompiFlen2y ago
okay wait because i said i would help you code one but if you are not willing to then im not gonna help
ɱ
ɱOP2y ago
yay i can send you what i have, it no workey
ShompiFlen
ShompiFlen2y ago
sure
ɱ
ɱOP2y 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
ShompiFlen2y ago
okay... so where does this fail what happens when you try to use it
ɱ
ɱOP2y 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
ShompiFlen2y ago
what version of discord.js are you using on this project? take a look at package.json
ɱ
ɱOP2y ago
14.14.4 i think
ɱ
ɱOP2y ago
i just noticed my package and package lock is missing im confused
ShompiFlen
ShompiFlen2y ago
you dont have a package.json in your project folder?
ɱ
ɱOP2y ago
i did idk what happend
ShompiFlen
ShompiFlen2y ago
might have to install dependencies again if you can't recover that
ɱ
ɱOP2y ago
its wtv i have a backup on github ill get later
ShompiFlen
ShompiFlen2y 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})
ɱ
ɱOP2y ago
i just did that lol
ɱ
ɱOP2y ago
Minoa
✿ ☆:.。. o(≧▽≦)o .。.:☆ ✿
lov u
ShompiFlen
ShompiFlen2y ago
alright, can you try running the command now and see what happens if it creates the emoji in the guild or not
ɱ
ɱOP2y ago
i forgor to define the guild whol up
ɱ
ɱOP2y ago
kinda works but the name is messed up https://thicc-thighs.com/g8t073df.png
Minoa
✿ ☆:.。. o(≧▽≦)o .。.:☆ ✿
lov u
ShompiFlen
ShompiFlen2y 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
ɱ
ɱOP2y ago
im fixxing it rn
ShompiFlen
ShompiFlen2y 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
ɱ
ɱOP2y ago
omfg i finnally got it yay
ShompiFlen
ShompiFlen2y ago
nice :Alfanod: feel free to resolve this post if you dont have any further questions :deusVult:

Did you find this page helpful?