Just getting back into discord bots
Recently just returned to going back to code my discord bot and notice that when i run the file i get "punnycode" module is deprecated. How do i fix this? Ive updated all dependencies to the current versions and still shows up. Tried to google it and nothing gives me a result to fix this
Versions:
Discord.js: 14.15.3
Node: 22.7.0
23 Replies
- 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!you can use
npm ls punycode
to see which package is using it and either replace it or just continue using it, ignoring the warning
however i don't think it's related to discord.jswhat would i use if i replaced punycode? or can i just use punycode for ever?
oh you're using it directly?
no i run the command above and got this
doesn't look like unirest will be updated any time soon, as it hasn't been for 5 years, why not just use axios or the native node fetch instead?
i dont know how to use them just saw unirest and learned that
unirest looks pretty similar to axios, i'm sure you'll be fine
there's not much to learn, it's just to make http requests anyway
truuuuuu
ok
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
i mean that's not really a long term solution
also got another question if u dont mind trying to figure this out it pops up when i try to run it, think it might be cause im missing sommething
ill just learn axios since uni is starting to go out dated kinda
it runs all the command files then shows this imm not sure what im looking at
imm thinking either a permission i forgot or something i didnt download
can you share the code where you're doing this rest request?
thats the thing im not sure cause each file has one
oh one sec
thought rest was something else ill show
require ('dotenv').config();
const { Client, GatewayIntentBits, Partials, Routes, Collection } = require('discord.js')
const client = new Client({
intents:[
GatewayIntentBits.GuildMessages,
GatewayIntentBits.Guilds,
GatewayIntentBits.MessageContent
],
rest: {version: '10'},
partials: [Partials.Channel]
});
const {TOKEN, APP, GUILD} = process.env;
const {registerCommands} = require('./handler/registercommand');
client.rest.setToken(TOKEN);
client.on('interactionCreate', (interaction) => {
if (interaction.isChatInputCommand()) {
const {commandName} = interaction;
const cmd = client.slashCommands.get(commandName);
if (cmd) {
cmd.execute(client, interaction);
}
else {
interaction.reply({content: 'Error running this slash command'});
}
}
});
async function main() {
try {
client.slashCommands = new Collection;
await registerCommands(client, '../commands');
//console.log(client.slashCommands);
const slashCommandsJson = client.slashCommands.map((cmd) => cmd.getSlashCommandJSON());
//console.log(slashCommandsJson);
await client.rest.put(Routes.applicationCommands(APP), {
body: slashCommandsJson,
});
const registeredSlashCommands = await client.rest.get(
Routes.applicationCommands(APP)
);
//console.log(registeredSlashCommands);
await client.login(TOKEN);
}
catch(err) {
console.log(err)
}
}
process.on("uncaughtException", (err) => {
console.error('Uncaught Exception:', err);
});
process.on("unhandledRejection", (reason, promise) => {
console.error("[FATAL] Possibly Unhandled Rejection at: Promise", promise, "\nreason:", reason.message);
});
main()
welp i was trying to put in a txt file -_-btw you can do
```js
<code>
```
to get codeblocks with syntax highlighting
ohh ok ty
seems like the
APP
variable is not your bot's idu know now that i think of it i do think so cause i remeber changing the token to another bot but not the app var.
just double check to be sure
also it's probably better to get the client's id in your code, instead of storing it inside of an .env file, because if you decide to switch bots you have to change 2 things in your .env instead of one
ok, also it works now thank you so much for helping me!
ill look up how to do that
glad to help 👍