Developer
Developer
DIAdiscord.js - Imagine an app
Created by Developer on 9/8/2024 in #djs-questions
Welcome message
I've created a welcome command that i can do /welcome channel and then in that channel everytime someone join the server there should be send a welcome message with an emebed, when someone joins it doens't work, so when i run the command it says: "Welcome messages will now be sent in generale" but then when someone joins he doesn't. welcome.js:
const { SlashCommandBuilder, EmbedBuilder, ChannelType, Client, GatewayIntentBits } = require('discord.js');

const client = new Client({ intents: [GatewayIntentBits.Guilds] });


let welcomeChannelId;

module.exports = {
data: new SlashCommandBuilder()
.setName('welcome')
.setDescription('Set the welcome channel for new members.')
.addChannelOption(option =>
option.setName('channel')
.setDescription('Channel where welcome messages will be sent')
.addChannelTypes(ChannelType.GuildText)
.setRequired(true)),

async execute(interaction) {
const channel = interaction.options.getChannel('channel');

if (!channel) {
return interaction.reply({ content: 'Please provide a valid text channel.', ephemeral: true });
}

welcomeChannelId = channel.id;

await interaction.reply(`Welcome messages will now be sent in ${channel.name}`);
},
};

client.on('guildMemberAdd', member => {
const channel = member.guild.channels.cache.get(welcomeChannelId);
if (!channel) return;

const embed = new EmbedBuilder()
.setColor(0x00AE86)
.setTitle(`Welcome ${member.user.username} to ${member.guild.name}!`)
.setDescription('Hope you\'ll have fun here!');

channel.send({ embeds: [embed] });
});
const { SlashCommandBuilder, EmbedBuilder, ChannelType, Client, GatewayIntentBits } = require('discord.js');

const client = new Client({ intents: [GatewayIntentBits.Guilds] });


let welcomeChannelId;

module.exports = {
data: new SlashCommandBuilder()
.setName('welcome')
.setDescription('Set the welcome channel for new members.')
.addChannelOption(option =>
option.setName('channel')
.setDescription('Channel where welcome messages will be sent')
.addChannelTypes(ChannelType.GuildText)
.setRequired(true)),

async execute(interaction) {
const channel = interaction.options.getChannel('channel');

if (!channel) {
return interaction.reply({ content: 'Please provide a valid text channel.', ephemeral: true });
}

welcomeChannelId = channel.id;

await interaction.reply(`Welcome messages will now be sent in ${channel.name}`);
},
};

client.on('guildMemberAdd', member => {
const channel = member.guild.channels.cache.get(welcomeChannelId);
if (!channel) return;

const embed = new EmbedBuilder()
.setColor(0x00AE86)
.setTitle(`Welcome ${member.user.username} to ${member.guild.name}!`)
.setDescription('Hope you\'ll have fun here!');

channel.send({ embeds: [embed] });
});
17 replies
DIAdiscord.js - Imagine an app
Created by Developer on 9/3/2024 in #djs-questions
Not loading ban command
With the basic command ping it works but with ban.js it doesn't. ping.js that works:
const { SlashCommandBuilder } = require('discord.js')

module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Testing 2'),
async execute(interaction) {
await interaction.reply('Pong!');
},
};
const { SlashCommandBuilder } = require('discord.js')

module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Testing 2'),
async execute(interaction) {
await interaction.reply('Pong!');
},
};
ban.js that doens't:
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('ban')
.setDescription('Ban a member')
.addUserOption(option =>
option
.setName('target')
.setDescription('The member to ban')
.setRequired(true))
.setDefaultMemberPermissions(PermissionFlagsBits.BanMembers)
.setDMPermission(false)
};
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('ban')
.setDescription('Ban a member')
.addUserOption(option =>
option
.setName('target')
.setDescription('The member to ban')
.setRequired(true))
.setDefaultMemberPermissions(PermissionFlagsBits.BanMembers)
.setDMPermission(false)
};
But if i put the same configuration as i have done with the ping command it works, but adding the .addUserOption it doesn't appear when i write /
17 replies
DIAdiscord.js - Imagine an app
Created by Developer on 9/2/2024 in #djs-questions
Can't use commands of other files
No description
10 replies