Izen
Izen
DIAdiscord.js - Imagine an app
Created by Izen 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
DIAdiscord.js - Imagine an app
Created by Izen 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
DIAdiscord.js - Imagine an app
Created by Izen on 7/8/2023 in #djs-questions
Issues With Permissions
78 replies
DIAdiscord.js - Imagine an app
Created by Izen on 7/3/2023 in #djs-questions
Issues with button builder
9 replies