Shadow
Shadow
DIAdiscord.js - Imagine an app
Created by Shadow on 2/10/2024 in #djs-questions
Bot status occasionally reverts back to initial status from the status set in ClientReady
so, shardReady doesnt really work in my case because it fires with ClientReady which is why I do it with a preiodic check like @gwapes suggested now
const client = new DiscordClient({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.DirectMessages,
],
presence: {
status: "dnd",
activities: [{ name: "Starting...", type: ActivityType.Playing }],
},
});

// ...

client.on(Events.ClientReady, async() => {
const guildCount = await client.guilds.fetch().then(guilds => guilds.size);

await registerCommands(client)
.then(() => client.on(Events.InteractionCreate, async interaction => interactionCreateHandler(interaction)));

client.user?.setActivity({ name: `Working on ${guildCount} servers!`, type: ActivityType.Playing });

let lastGuildCount = guildCount;
setInterval(async() => {
const newGuildCount = await client.guilds.fetch().then(guilds => guilds.size);
const statusHasReset = client.user?.presence.activities[0].name === "Starting...";

if (newGuildCount !== lastGuildCount || statusHasReset){
lastGuildCount = newGuildCount;
client.user?.setActivity({ name: `Working on ${newGuildCount} servers!`, type: ActivityType.Playing });
}
}, 5 * 60 * 1000);

client.user?.setStatus("online");
});
const client = new DiscordClient({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.DirectMessages,
],
presence: {
status: "dnd",
activities: [{ name: "Starting...", type: ActivityType.Playing }],
},
});

// ...

client.on(Events.ClientReady, async() => {
const guildCount = await client.guilds.fetch().then(guilds => guilds.size);

await registerCommands(client)
.then(() => client.on(Events.InteractionCreate, async interaction => interactionCreateHandler(interaction)));

client.user?.setActivity({ name: `Working on ${guildCount} servers!`, type: ActivityType.Playing });

let lastGuildCount = guildCount;
setInterval(async() => {
const newGuildCount = await client.guilds.fetch().then(guilds => guilds.size);
const statusHasReset = client.user?.presence.activities[0].name === "Starting...";

if (newGuildCount !== lastGuildCount || statusHasReset){
lastGuildCount = newGuildCount;
client.user?.setActivity({ name: `Working on ${newGuildCount} servers!`, type: ActivityType.Playing });
}
}, 5 * 60 * 1000);

client.user?.setStatus("online");
});
11 replies
DIAdiscord.js - Imagine an app
Created by Shadow on 2/10/2024 in #djs-questions
Bot status occasionally reverts back to initial status from the status set in ClientReady
alright, I see. thanks! :)
11 replies
DIAdiscord.js - Imagine an app
Created by Shadow on 2/10/2024 in #djs-questions
Bot status occasionally reverts back to initial status from the status set in ClientReady
the presence isn't static. ill give shardReady a try. whats the difference between that and shardResume?
11 replies
DIAdiscord.js - Imagine an app
Created by Shadow on 2/10/2024 in #djs-questions
Bot status occasionally reverts back to initial status from the status set in ClientReady
Nah I don't think an interval is a good solution. Since somehow the client options are re-set under a certain condition without calling ClientReady again, I assume the shard is re-initialized. Which means I should be able to set the status again by catching the ShardResume event. but since I can't really test that I thought I'd ask here first
11 replies
DIAdiscord.js - Imagine an app
Created by Shadow on 5/27/2023 in #djs-questions
Can't use Emoji from other Server in followUp.
thanks for taking the time to help! :)
11 replies
DIAdiscord.js - Imagine an app
Created by Shadow on 5/27/2023 in #djs-questions
Can't use Emoji from other Server in followUp.
yea .replied could work too. but just had a brain lag. its not even needed
11 replies
DIAdiscord.js - Imagine an app
Created by Shadow on 5/27/2023 in #djs-questions
Can't use Emoji from other Server in followUp.
actually, doesn't matter. those replies don't use emotes and having that "prefix" followUp before the last reply is a failsafe in any case
11 replies
DIAdiscord.js - Imagine an app
Created by Shadow on 5/27/2023 in #djs-questions
Can't use Emoji from other Server in followUp.
hmmmm
11 replies
DIAdiscord.js - Imagine an app
Created by Shadow on 5/27/2023 in #djs-questions
Can't use Emoji from other Server in followUp.
Ohhhh, I see! So because of my deferReply (bot takes a while to compute) the first followUp is just an editReply under the hood. Sorry, didn't understand that at first. Yea with the second follow up it works too. That opens another can of worms now tho since between the deferReply and the embed send reply there are potential followUps in between if something goes wrong / cant be parsed / etc
11 replies
DIAdiscord.js - Imagine an app
Created by Shadow on 5/27/2023 in #djs-questions
Can't use Emoji from other Server in followUp.
--- Also thanks for the answer and the valuable insights!
11 replies
DIAdiscord.js - Imagine an app
Created by Shadow on 5/27/2023 in #djs-questions
Can't use Emoji from other Server in followUp.
Eh ill just use the followUp to "prefix" the actual reply. Its a bit ugly but whatevs.
await interaction.followUp("Shop:");
return await interaction.channel.send({
embeds: [embed],
// ...
});
await interaction.followUp("Shop:");
return await interaction.channel.send({
embeds: [embed],
// ...
});
11 replies
DIAdiscord.js - Imagine an app
Created by Shadow on 5/27/2023 in #djs-questions
Can't use Emoji from other Server in followUp.
oof. So I'm still better off with just using .send() instead of .followUp() because seems like UseExternalEmojis isn't set on everyone per default. and I can't have my embed fail on server that didn't explicitly set the permission. Is it an actual confirmed bug or is it just discord not caring again?
11 replies
DIAdiscord.js - Imagine an app
Created by Shadow on 5/27/2023 in #djs-questions
Can't use Emoji from other Server in followUp.
DJS: discord.js@14.11.0 Node: v20.0.0
11 replies