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