Tincho
Tincho
DIAdiscord.js - Imagine an app
Created by Tincho on 3/18/2024 in #djs-questions
setNickName limitations
Hi everyone! I have a bot that changes its nickname every time a websocket is updated (around 10/15 seconds) and I can't find the problem why it stops changing. As a test, I made this method that I call every 1 second and you can see that after change #20 it stops updating. As I checked on the Discord developers discord insert spiderman meme here the API has a limitation that "it is returned in the response headers", but I don't know how to handle it from discord.js. Can anyone help me?
client.guilds.cache.forEach((guild) => {
if (nickname != guild.members.me?.nickname) {
debug(
`Updating nickname of ${guild.members.me?.displayName} to ${nickname}`
);
guild.members.me
?.setNickname(nickname)
.then((m) => debug("Nickname updated %O", m.nickname))
.catch((e) => error(e));
}
});
client.guilds.cache.forEach((guild) => {
if (nickname != guild.members.me?.nickname) {
debug(
`Updating nickname of ${guild.members.me?.displayName} to ${nickname}`
);
guild.members.me
?.setNickname(nickname)
.then((m) => debug("Nickname updated %O", m.nickname))
.catch((e) => error(e));
}
});
Output
bot-btc:updateNick:debug Updating nickname of 0 to 1 +0ms
bot-btc:updateNick:debug Nickname updated '1' +301ms
bot-btc:updateNick:debug Updating nickname of 1 to 2 +0ms
bot-btc:updateNick:debug Nickname updated '2' +247ms
[...]
bot-btc:updateNick:debug Updating nickname of 18 to 19 +0ms
bot-btc:updateNick:debug Nickname updated '19' +797ms
bot-btc:updateNick:debug Updating nickname of 19 to 20 +0ms
bot-btc:updateNick:debug Nickname updated '20' +334ms
bot-btc:updateNick:debug Updating nickname of 20 to 21 +0ms
bot-btc:updateNick:debug Updating nickname of 20 to 22 +0ms
bot-btc:updateNick:debug Updating nickname of 20 to 23 +0ms
bot-btc:updateNick:debug Updating nickname of 20 to 24 +0ms
bot-btc:updateNick:debug Updating nickname of 20 to 25 +0ms
bot-btc:updateNick:debug Updating nickname of 0 to 1 +0ms
bot-btc:updateNick:debug Nickname updated '1' +301ms
bot-btc:updateNick:debug Updating nickname of 1 to 2 +0ms
bot-btc:updateNick:debug Nickname updated '2' +247ms
[...]
bot-btc:updateNick:debug Updating nickname of 18 to 19 +0ms
bot-btc:updateNick:debug Nickname updated '19' +797ms
bot-btc:updateNick:debug Updating nickname of 19 to 20 +0ms
bot-btc:updateNick:debug Nickname updated '20' +334ms
bot-btc:updateNick:debug Updating nickname of 20 to 21 +0ms
bot-btc:updateNick:debug Updating nickname of 20 to 22 +0ms
bot-btc:updateNick:debug Updating nickname of 20 to 23 +0ms
bot-btc:updateNick:debug Updating nickname of 20 to 24 +0ms
bot-btc:updateNick:debug Updating nickname of 20 to 25 +0ms
19 replies
DIAdiscord.js - Imagine an app
Created by Tincho on 7/27/2023 in #djs-questions
Send lightning network lnurlp link
I'm starting to develop a bot in typescript with discord.js v14 and a command from the bot generates a lightning network (bitcoin layer 2) invoice to receive donations. As a response, an embed is generated with a qr to scan with an LN wallet, but if the user generates it from the same smartphone it can be difficult to scan the qr, so it occurred to me to also send a link so that they can tap and open their wallet, but I can't generate it like lightning://lnbc..... Any ideas?
13 replies