maybeizen
maybeizen
DIdiscord.js - Imagine ❄
Created by maybeizen on 11/8/2024 in #djs-questions
Mentioning commands that have subcommands.
I have a question regarding how to properly mention commands that have subcommands in a bot. For example, I have a /status command, with the subcommands /status bot and /status api. While I understand that this is a Discord-related issue, I am trying to implement this functionality in my bot. I have structured the commands in an array, with each command being an object. However, when trying to mention the commands using the following code, it works for all commands except those that contain subcommands:
let commandString = `- </${command.name}:${command.id}> - ${command.description}`;
let commandString = `- </${command.name}:${command.id}> - ${command.description}`;
Could you provide any insights into how I might address this issue?
3 replies
DIdiscord.js - Imagine ❄
Created by maybeizen on 7/12/2024 in #djs-questions
Function always returns "true".
Hi everyone, I've created a function that checks if a user can be DMed. However, it always returns true, regardless of the user's permissions. Here's the snippet:
async function checkDm(user) {
try {
user.createDM();
return true;
} catch (error) {
return false;
}
}
async function checkDm(user) {
try {
user.createDM();
return true;
} catch (error) {
return false;
}
}
I've been testing it on myself, but it consistently returns true, even when it shouldn't. The function should catch an error at user.createDM(), but it doesn't seem to. I might be overlooking something. Might someone help me point out the issue?
7 replies
DIdiscord.js - Imagine ❄
Created by maybeizen on 10/25/2023 in #djs-questions
Pulling API Data in DiscordJS
So, I'm not a pro and I don't understand what the docs are talking about for pulling data from APIs, so can someone help me with this? I am making a bot for a Minecraft Discord server, and want to use https://api.mcsrvstat.us/3/ as an API for pulling the data, but I really don't know how. - This is what I have so far and I know it needs a lot of fixing. - Does someone mind helping me fix this or understand it a little bit better?
const {
EmbedBuilder,
ButtonBuilder,
ActionRowBuilder,
SlashCommandBuilder,
ButtonStyle,
} = require("discord.js");

module.exports = {
name: "status",
description: "Basic info about Kasai's World, such as player count.",

callback: async (client, interaction) => {
interaction.reply(`${online}`);

client.on(Events.InteractionCreate, async (interaction) => {
const term = interaction.options.getString("term");
const query = new URLSearchParams({ term });

const statusResult = await request(
`https://api.mcsrvstat.us/3/world.kasaisora.com`
);
const { list } = await statusResult.body.json();
});
},
};
const {
EmbedBuilder,
ButtonBuilder,
ActionRowBuilder,
SlashCommandBuilder,
ButtonStyle,
} = require("discord.js");

module.exports = {
name: "status",
description: "Basic info about Kasai's World, such as player count.",

callback: async (client, interaction) => {
interaction.reply(`${online}`);

client.on(Events.InteractionCreate, async (interaction) => {
const term = interaction.options.getString("term");
const query = new URLSearchParams({ term });

const statusResult = await request(
`https://api.mcsrvstat.us/3/world.kasaisora.com`
);
const { list } = await statusResult.body.json();
});
},
};
4 replies
DIdiscord.js - Imagine ❄
Created by maybeizen on 7/8/2023 in #djs-questions
Issues With Permissions
78 replies
DIdiscord.js - Imagine ❄
Created by maybeizen on 7/3/2023 in #djs-questions
Issues with button builder
9 replies