mar
mar
DIAdiscord.js - Imagine an app
Created by mar on 12/11/2023 in #djs-questions
Adding an array to embed fields
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js")
const { getTodos } = require("../../firebase.js");

module.exports = {
data: new SlashCommandBuilder()
.setName("todues")
.setDescription("Gets a list of ToDues"),
async execute(interaction){
const todoEmbed = new EmbedBuilder()
.setColor("DarkVividPink")
.setDescription("A list of all your todos.")
try {
const userId = interaction.user.id;
await interaction.deferReply();

const todos = await getTodos(userId);

await interaction.editReply({embeds: [todoEmbed]})
} catch (error) {
console.error(error);
await interaction.editReply("An error occurred while fetching tasks.");
}
},
}
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js")
const { getTodos } = require("../../firebase.js");

module.exports = {
data: new SlashCommandBuilder()
.setName("todues")
.setDescription("Gets a list of ToDues"),
async execute(interaction){
const todoEmbed = new EmbedBuilder()
.setColor("DarkVividPink")
.setDescription("A list of all your todos.")
try {
const userId = interaction.user.id;
await interaction.deferReply();

const todos = await getTodos(userId);

await interaction.editReply({embeds: [todoEmbed]})
} catch (error) {
console.error(error);
await interaction.editReply("An error occurred while fetching tasks.");
}
},
}
"todos" returns an array that follow the same structure that the fields of an embed use. I want to this as the "name" and "value" of the field how can I achieve this?
3 replies
DIAdiscord.js - Imagine an app
Created by mar on 5/23/2023 in #djs-questions
Accessing direct messages?
Hi I am trying to see whenever my bot was DM'ed and then send the dm to myself , the first part I was testing for this was just alerting when a DM wa receieved but for some reason its not working? My code:
const { Client, IntentsBitField, Message, InteractionCollector, DMChannel } = require('discord.js');
require('dotenv').config()


const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
]
});


client.on('messageCreate', message => {
if (message.channel.type === 1) {
console.log('Dm recieved!');
}
});
const { Client, IntentsBitField, Message, InteractionCollector, DMChannel } = require('discord.js');
require('dotenv').config()


const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
]
});


client.on('messageCreate', message => {
if (message.channel.type === 1) {
console.log('Dm recieved!');
}
});
7 replies