Shahar
Shahar
DIAdiscord.js - Imagine an app
Created by Shahar on 9/30/2024 in #djs-questions
memory
my bot is across 10,000 guilds with 10 shards, each shard is approximal needs 550-750mb I am using the following intents:
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildWebhooks,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
],
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildWebhooks,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
],
and those are the sweepers:
sweepers: {
...Options.DefaultSweeperSettings,
messages: {
interval: 3600,
lifetime: 3600,
},
users: {
interval: 23200,
filter: () => user => user.id !== client.user.id
},
presences:{
interval: 1800,
filter: () => presence => presence.user.id !== client.user.id
}
}
sweepers: {
...Options.DefaultSweeperSettings,
messages: {
interval: 3600,
lifetime: 3600,
},
users: {
interval: 23200,
filter: () => user => user.id !== client.user.id
},
presences:{
interval: 1800,
filter: () => presence => presence.user.id !== client.user.id
}
}
please ignore the presences filter I just wanted to completely clear it because it was consuming so much memory . any idea of how to monitor the bottle neck or what causes this consumption? (just for instances I am not using big dicts or anything like that mostly there is calls to db and there is nothing cached aprat djs cache) using default library's :
"axios": "^1.4.0",
"discord.js": "14.16.1",
"dotenv": "16.1.3",
"mongoose": "7.2.2",
"winston": "3.9.0"
"axios": "^1.4.0",
"discord.js": "14.16.1",
"dotenv": "16.1.3",
"mongoose": "7.2.2",
"winston": "3.9.0"
7 replies
DIAdiscord.js - Imagine an app
Created by Shahar on 9/28/2024 in #djs-questions
Permissions
is there a way to know what permissions my bot has in a specific channel? (ignoring the role permissions he has when we got to the guild) because when I use interaction.channel.permissionsFor(interaction.guild.members.me) returns the combined permissions he has in role perspective and channel
30 replies
DIAdiscord.js - Imagine an app
Created by Shahar on 9/18/2024 in #djs-questions
PERMISIONS BITFIELD
someone has an idea how to write it better and also make this thing work? im checking for names instead of bitfield and I need to return a string at the end of the day to let the user know what permissions are missing:
const requiredPermissions = [
PermissionsBitField.Flags.ViewChannel,
PermissionsBitField.Flags.ManageChannels,
PermissionsBitField.Flags.ManageRoles,
PermissionsBitField.Flags.SendMessages,
PermissionsBitField.Flags.EmbedLinks
];
const botPermissions = interaction.guild.members.me.permissions;
const missingPermissions = requiredPermissions.filter(permission => !botPermissions.has(permission));
const missingPermissionNames = missingPermissions.map(permission=>{
switch (permission) {
case PermissionsBitField.Flags.ViewChannel:
return 'View Channels';
case PermissionsBitField.Flags.ManageChannels:
return 'Manage Channels';
case PermissionsBitField.Flags.ManageRoles:
return 'Manage Roles';
case PermissionsBitField.Flags.SendMessages:
return 'Send Messages';
case PermissionsBitField.Flags.EmbedLinks:
return 'Embed Links';
default:
return 'Unknown Permission';
}
});
const requiredPermissions = [
PermissionsBitField.Flags.ViewChannel,
PermissionsBitField.Flags.ManageChannels,
PermissionsBitField.Flags.ManageRoles,
PermissionsBitField.Flags.SendMessages,
PermissionsBitField.Flags.EmbedLinks
];
const botPermissions = interaction.guild.members.me.permissions;
const missingPermissions = requiredPermissions.filter(permission => !botPermissions.has(permission));
const missingPermissionNames = missingPermissions.map(permission=>{
switch (permission) {
case PermissionsBitField.Flags.ViewChannel:
return 'View Channels';
case PermissionsBitField.Flags.ManageChannels:
return 'Manage Channels';
case PermissionsBitField.Flags.ManageRoles:
return 'Manage Roles';
case PermissionsBitField.Flags.SendMessages:
return 'Send Messages';
case PermissionsBitField.Flags.EmbedLinks:
return 'Embed Links';
default:
return 'Unknown Permission';
}
});
12 replies
DIAdiscord.js - Imagine an app
Created by Shahar on 1/28/2024 in #djs-questions
Audit log
is there a way to hide logs of the bot from audit log? for example "move member" or "channel create"
3 replies
DIAdiscord.js - Imagine an app
Created by Shahar on 11/6/2023 in #djs-questions
Service Unavailable
My bot is running for 23 days with no issues. I came across this following error trying to delete a channel:
HTTPError: Service Unavailable
0|index | at handleErrors (/home/ec2-user/node_modules/@discordjs/rest/dist/index.js:680:11)
0|index | at SequentialHandler.runRequest (/home/ec2-user/node_modules/@discordjs/rest/dist/index.js:1072:29)
0|index | at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
0|index | at async SequentialHandler.queueRequest (/home/ec2-user/node_modules/@discordjs/rest/dist/index.js:913:14)
0|index | at async _REST.request (/home/ec2-user/node_modules/@discordjs/rest/dist/index.js:1218:22)
0|index | at async GuildChannelManager.delete (/home/ec2-user/node_modules/discord.js/src/managers/GuildChannelManager.js:498:5)
0|index | at async VoiceChannel.delete (/home/ec2-user/node_modules/discord.js/src/structures/GuildChannel.js:467:5)
0|index | at async deleteChannel (/home/ec2-user/events/voiceStateUpdate.js:90:9)
0|index | at async Object.execute (/home/ec2-user/events/voiceStateUpdate.js:46:17) {
0|index | requestBody: { files: undefined, json: undefined },
0|index | status: 503,
0|index | method: 'DELETE',
0|index | url: 'https://discord.com/api/v10/channels/1171159930980536321'
0|index | }
HTTPError: Service Unavailable
0|index | at handleErrors (/home/ec2-user/node_modules/@discordjs/rest/dist/index.js:680:11)
0|index | at SequentialHandler.runRequest (/home/ec2-user/node_modules/@discordjs/rest/dist/index.js:1072:29)
0|index | at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
0|index | at async SequentialHandler.queueRequest (/home/ec2-user/node_modules/@discordjs/rest/dist/index.js:913:14)
0|index | at async _REST.request (/home/ec2-user/node_modules/@discordjs/rest/dist/index.js:1218:22)
0|index | at async GuildChannelManager.delete (/home/ec2-user/node_modules/discord.js/src/managers/GuildChannelManager.js:498:5)
0|index | at async VoiceChannel.delete (/home/ec2-user/node_modules/discord.js/src/structures/GuildChannel.js:467:5)
0|index | at async deleteChannel (/home/ec2-user/events/voiceStateUpdate.js:90:9)
0|index | at async Object.execute (/home/ec2-user/events/voiceStateUpdate.js:46:17) {
0|index | requestBody: { files: undefined, json: undefined },
0|index | status: 503,
0|index | method: 'DELETE',
0|index | url: 'https://discord.com/api/v10/channels/1171159930980536321'
0|index | }
line 90: await channel.delete();
6 replies
DIAdiscord.js - Imagine an app
Created by Shahar on 10/14/2023 in #djs-questions
Ephemeral messages
Is there a way to fetch the ephemeral messages sent to a specific user in a channel in order to delete them? Or do I need to store the token and message id in order to delete them?
2 replies
DIAdiscord.js - Imagine an app
Created by Shahar on 7/11/2023 in #djs-questions
guildCreate
is there a way to check who invited the bot to the guild without using auditlog?
3 replies
DIAdiscord.js - Imagine an app
Created by Shahar on 6/18/2023 in #djs-questions
Question about GuildChannel
<GuildChannel>.members(memberId)
<GuildChannel>.members(memberId)
how can i check if a certain member connected to the voice
7 replies
DIAdiscord.js - Imagine an app
Created by Shahar on 6/17/2023 in #djs-questions
permissionOverwrites
interaction.channel.permissionOverwrites.delete(member).catch(console.error);
interaction.channel.permissionOverwrites.delete(member).catch(console.error);
is it ok to supply a userid or roleid to delete a permission?
2 replies
DIAdiscord.js - Imagine an app
Created by Shahar on 6/11/2023 in #djs-questions
displayName
I want to get the profile name on the current server of the user. currently I use it as following:
channelName.replace('{user}', `${member.displayName}`);
channelName.replace('{user}', `${member.displayName}`);
(<newstate>.member.displayName) The new update takes the username instead of the displayName it used to be.
5 replies
DIAdiscord.js - Imagine an app
Created by Shahar on 6/3/2023 in #djs-questions
insufficient permission
how can I check if my bot has permission of administrator on the event interactionCreate, so I wont get insufficient permission ?
4 replies
DIAdiscord.js - Imagine an app
Created by Shahar on 6/2/2023 in #djs-questions
userse
Hello, what is the correct event I need to use in order to monitor a permission that changed on specific channel, for example if a "everyone" role ViewChannel/Connect permission has been changed to 'x'
24 replies
DIAdiscord.js - Imagine an app
Created by Shahar on 5/30/2023 in #djs-questions
inherit roles from a channel
7 replies
DIAdiscord.js - Imagine an app
Created by Shahar on 5/29/2023 in #djs-questions
Fetch ephemeral message
Is it possible to store the id of a message and then fetch it later on in order to delete it? I was able to delete the message if i store the promise<message> but otherwise I couldn’t find a way to delete an ephemeral message
28 replies
DIAdiscord.js - Imagine an app
Created by Shahar on 5/28/2023 in #djs-questions
Is there any extensions and tools available that provide autocompletion for discord.js using Visual
title
20 replies