Black_Wither
Black_Wither
DIAdiscord.js - Imagine an app
Created by Black_Wither on 5/11/2024 in #djs-questions
Wrong user count
const { EmbedBuilder, ApplicationCommandType, time, version } = require('discord.js');
const botJSON = require('../../package.json');
const config = require("../../config.json");
const superagent = require("superagent");

const apiURL = "https://api.wolvesville.com/";

async function getVerifiedGuildsCount() {
return new Promise(function(resolve, reject) {
superagent
.get(apiURL + `clans/authorized`)
.set("Authorization", `Bot ${config.wolvesvilleKey}`)
.end(async (err, res) => {
resolve(res.body.length)
})
})
}

module.exports = {
name: 'bot-info',
description: "» Shows all important information about the bot",
cooldown: 3000,
type: ApplicationCommandType.ChatInput,
options: [],
run: async (client, interaction) => {

const authorizedGuilds = await getVerifiedGuildsCount();
const guilds = client.guilds.cache.size.toLocaleString("de-DE");
const users = client.users.cache.size.toLocaleString("de-DE");

const inviteUrl = `https://discord.com/api/oauth2/authorize?client_id=${config.clientId}&permissions=8&scope=bot%20applications.commands`;
const embed = new EmbedBuilder()
.setTitle("🤖 » **__BOT INFO__**")
.setColor("#FF4181")
.setDescription("Here you find all information about the bot.")
.setThumbnail(client.user.displayAvatarURL())
.addFields(
{ name: "Bot version", value: ":pink_bot: `" + botJSON.version + "`", inline: true },
{ name: "Discord.js version", value: ":pink_dev: `" + version + "`", inline: true },
{ name: "Uptime", value: ":pink_time: " + time(Math.floor((Date.now() - client.uptime) / 1000), "R"), inline: true },
{ name: "Servers", value: ":pink_navigation: `" + guilds + "`", inline: true },
{ name: "Users", value: ":pink_users: `" + users + "`", inline: true },
{ name: "Authorized clans", value: ":shield: `" + authorizedGuilds.toString() + "`", inline: true },
{
name: "Invite Link:",
value: `:pink_link: [Click here](${inviteUrl})`,
inline: true
},
{
name: "Support server",
value: `:pink_link: [Click here](https://discord.gg/QzyyXzr8Up)`,
inline: true
}
)
.setFooter({ text: "Created by @black_wither" });

interaction.reply({ embeds: [embed] })
}
};
const { EmbedBuilder, ApplicationCommandType, time, version } = require('discord.js');
const botJSON = require('../../package.json');
const config = require("../../config.json");
const superagent = require("superagent");

const apiURL = "https://api.wolvesville.com/";

async function getVerifiedGuildsCount() {
return new Promise(function(resolve, reject) {
superagent
.get(apiURL + `clans/authorized`)
.set("Authorization", `Bot ${config.wolvesvilleKey}`)
.end(async (err, res) => {
resolve(res.body.length)
})
})
}

module.exports = {
name: 'bot-info',
description: "» Shows all important information about the bot",
cooldown: 3000,
type: ApplicationCommandType.ChatInput,
options: [],
run: async (client, interaction) => {

const authorizedGuilds = await getVerifiedGuildsCount();
const guilds = client.guilds.cache.size.toLocaleString("de-DE");
const users = client.users.cache.size.toLocaleString("de-DE");

const inviteUrl = `https://discord.com/api/oauth2/authorize?client_id=${config.clientId}&permissions=8&scope=bot%20applications.commands`;
const embed = new EmbedBuilder()
.setTitle("🤖 » **__BOT INFO__**")
.setColor("#FF4181")
.setDescription("Here you find all information about the bot.")
.setThumbnail(client.user.displayAvatarURL())
.addFields(
{ name: "Bot version", value: ":pink_bot: `" + botJSON.version + "`", inline: true },
{ name: "Discord.js version", value: ":pink_dev: `" + version + "`", inline: true },
{ name: "Uptime", value: ":pink_time: " + time(Math.floor((Date.now() - client.uptime) / 1000), "R"), inline: true },
{ name: "Servers", value: ":pink_navigation: `" + guilds + "`", inline: true },
{ name: "Users", value: ":pink_users: `" + users + "`", inline: true },
{ name: "Authorized clans", value: ":shield: `" + authorizedGuilds.toString() + "`", inline: true },
{
name: "Invite Link:",
value: `:pink_link: [Click here](${inviteUrl})`,
inline: true
},
{
name: "Support server",
value: `:pink_link: [Click here](https://discord.gg/QzyyXzr8Up)`,
inline: true
}
)
.setFooter({ text: "Created by @black_wither" });

interaction.reply({ embeds: [embed] })
}
};
Every time that I run the command again, the users var will increase insane, for example every second +10 members. The first where I use the command after every restart, it will give me the correct userCount. Can anyone tell me how to fix that?
14 replies
DIAdiscord.js - Imagine an app
Created by Black_Wither on 3/29/2024 in #djs-questions
Locale Descriptions
Hey I'm currently trying to use locale description with my bot. I have following code which is not working:
slashCommands.push({
name: slashCommand.name,
description: slashCommand.description,
descriptionLocalizations: slashCommand.descriptionLocalizations ? slashCommand.descriptionLocalizations : null,
type: slashCommand.type,
options: slashCommand.options ? slashCommand.options : null,
default_permission: slashCommand.default_permission ? slashCommand.default_permission : null,
default_member_permissions: slashCommand.default_member_permissions ? PermissionsBitField.resolve(slashCommand.default_member_permissions).toString() : null
});
slashCommands.push({
name: slashCommand.name,
description: slashCommand.description,
descriptionLocalizations: slashCommand.descriptionLocalizations ? slashCommand.descriptionLocalizations : null,
type: slashCommand.type,
options: slashCommand.options ? slashCommand.options : null,
default_permission: slashCommand.default_permission ? slashCommand.default_permission : null,
default_member_permissions: slashCommand.default_member_permissions ? PermissionsBitField.resolve(slashCommand.default_member_permissions).toString() : null
});
`
await rest.put(
GUILD_ID ?
Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID) :
Routes.applicationCommands(CLIENT_ID),
{ body: slashCommands }
);
await rest.put(
GUILD_ID ?
Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID) :
Routes.applicationCommands(CLIENT_ID),
{ body: slashCommands }
);
imports:
const { PermissionsBitField } = require('discord.js');
const { Routes } = require('discord-api-types/v9');
const { REST } = require('@discordjs/rest')
const { PermissionsBitField } = require('discord.js');
const { Routes } = require('discord-api-types/v9');
const { REST } = require('@discordjs/rest')
dependencies:
"@discordjs/rest": "^0.4.0-dev.1648166871.cedd053",
"discord-api-types": "^0.30.0",
"discord.js": "^14.12.1",
"@discordjs/rest": "^0.4.0-dev.1648166871.cedd053",
"discord-api-types": "^0.30.0",
"discord.js": "^14.12.1",
4 replies
DIAdiscord.js - Imagine an app
Created by Black_Wither on 3/1/2024 in #djs-questions
MessageCreate API
No description
5 replies
DIAdiscord.js - Imagine an app
Created by Black_Wither on 1/8/2024 in #djs-questions
Canva Image to .setImage()
How can I add a @napi-rs/canvas image to a embed as image in a .setImage function?
9 replies
DIAdiscord.js - Imagine an app
Created by Black_Wither on 10/15/2023 in #djs-questions
Can‘t find message by id
I can‘t fetch a message by his id. The error: const clockInMessage = await user.messages.fetch(worker.clockInMessage); 3|segritude | ^ 3|segritude | TypeError: Cannot read properties of undefined (reading 'fetch')
9 replies
DIAdiscord.js - Imagine an app
Created by Black_Wither on 8/3/2023 in #djs-questions
REST dont make Slash Commands
My guild Slash Commands dont register any more A few days ago, all was still working. But I added a context menu handler to my bot with a similar code what I has taken for my guild Slash Commands.
(async () => {
try {
await rest.put(
GUILD_ID ?
Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID) :
Routes.applicationCommands(CLIENT_ID),
{ body: slashCommands }
);
console.log(chalk.yellow('Slash Commands • Registered'))
} catch (error) {
console.log(error);
}
})();
(async () => {
try {
await rest.put(
GUILD_ID ?
Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID) :
Routes.applicationCommands(CLIENT_ID),
{ body: slashCommands }
);
console.log(chalk.yellow('Slash Commands • Registered'))
} catch (error) {
console.log(error);
}
})();
My problem is, that the context menus are still working after deleting the context menu handler file and the slash commands dont register.
12 replies
DIAdiscord.js - Imagine an app
Created by Black_Wither on 7/28/2023 in #djs-questions
create context menus
I get no error, but no context Menus are created after start the bot:

const rest = new REST({ version: '9' }).setToken(TOKEN);

module.exports = (client) => {
const contextMenus = [];

fs.readdirSync('./contextMenus/').forEach(async dir => {
const files = fs.readdirSync(`./contextMenus/${dir}/`).filter(file => file.endsWith('.js'));

for(const file of files) {
const contextMenu = require(`../contextMenus/${dir}/${file}`);
new ContextMenuCommandBuilder()
.setName(contextMenu.name)
.setType(contextMenu.type);



contextMenus.push({
name: contextMenu.name,
type: contextMenu.type,
default_permission: contextMenu.default_permission ? contextMenu.default_permission : null,
default_member_permissions: contextMenu.default_member_permissions ? PermissionsBitField.resolve(contextMenu.default_member_permissions).toString() : null
});

if(contextMenu.name) {
client.contextMenus.set(contextMenu.name, contextMenu)
table.addRow(file.split('.js')[0], '✅')

} else {
table.addRow(file.split('.js')[0], '⛔')
}
}

});
console.log(chalk.hex("4c0bad")(table.toString()));

(async () => {
try {
//await rest.put(
//Routes.contextMenuCommand(CLIENT_ID),
// { body: contextMenu }
// );

console.log(chalk.blue('Context Menus • Registered'))
} catch (error) {
console.log(error);
}
})();
};

const rest = new REST({ version: '9' }).setToken(TOKEN);

module.exports = (client) => {
const contextMenus = [];

fs.readdirSync('./contextMenus/').forEach(async dir => {
const files = fs.readdirSync(`./contextMenus/${dir}/`).filter(file => file.endsWith('.js'));

for(const file of files) {
const contextMenu = require(`../contextMenus/${dir}/${file}`);
new ContextMenuCommandBuilder()
.setName(contextMenu.name)
.setType(contextMenu.type);



contextMenus.push({
name: contextMenu.name,
type: contextMenu.type,
default_permission: contextMenu.default_permission ? contextMenu.default_permission : null,
default_member_permissions: contextMenu.default_member_permissions ? PermissionsBitField.resolve(contextMenu.default_member_permissions).toString() : null
});

if(contextMenu.name) {
client.contextMenus.set(contextMenu.name, contextMenu)
table.addRow(file.split('.js')[0], '✅')

} else {
table.addRow(file.split('.js')[0], '⛔')
}
}

});
console.log(chalk.hex("4c0bad")(table.toString()));

(async () => {
try {
//await rest.put(
//Routes.contextMenuCommand(CLIENT_ID),
// { body: contextMenu }
// );

console.log(chalk.blue('Context Menus • Registered'))
} catch (error) {
console.log(error);
}
})();
};
6 replies
DIAdiscord.js - Imagine an app
Created by Black_Wither on 5/27/2023 in #djs-questions
Create Forum Tags
Hey, how can I create Forum Tags? I try it on discord.js
8 replies