Skip to content

Commit

Permalink
fix: bugs, major changes
Browse files Browse the repository at this point in the history
Fixed help commands and improved
Fixed music play and currenty disable
updated event with embed

Co-Authored-By: Vipulbhai Chaudhary <152608930+nexos-crafter@users.noreply.github.com>
  • Loading branch information
nexoscreator and nexos-crafter committed Jul 16, 2024
1 parent 6115428 commit 43301af
Show file tree
Hide file tree
Showing 12 changed files with 112 additions and 47 deletions.
76 changes: 47 additions & 29 deletions commands/basics/help.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,49 @@
const { EmbedBuilder } = require('discord.js');

module.exports = {
name: 'help',
description: 'List all commands or info about a specific command.',
execute(message, args) {
const data = [];
const { commands } = message.client;

if (!args.length) {
data.push('Here\'s a list of all my commands:');
data.push(commands.map(command => command.name).join(', '));
data.push(`\nYou can send \`${process.env.BOT_PREFIX}help [command name]\` to get info on a specific command!`);

return message.channel.send(data, { split: true });
}

const name = args[0].toLowerCase();
const command = commands.get(name) || commands.find(c => c.aliases && c.aliases.includes(name));

if (!command) {
return message.reply('That\'s not a valid command!');
}

data.push(`**Name:** ${command.name}`);

if (command.description) data.push(`**Description:** ${command.description}`);
if (command.usage) data.push(`**Usage:** ${process.env.BOT_PREFIX}${command.name} ${command.usage}`);

message.channel.send(data, { split: true });
name: 'help',
description: 'List all commands or info about a specific command.',
options: [
{
name: 'command',
type: 'STRING',
description: 'The command to get information about',
required: false,
},
};

],
execute(message, args) {
const { commands } = message.client;

if (!args.length) {
const helpEmbed = new EmbedBuilder()
.setColor('#0099ff')
.setTitle('Help - List of Commands')
.setDescription('Here\'s a list of all my commands:')
.addFields(
{ name: 'Commands', value: commands.map(command => `\`${command.name}\`: ${command.description}`).join('\n') },
{ name: 'Usage', value: `You can send \`${process.env.BOT_PREFIX}help [command name]\` to get info on a specific command!` }
)
.setFooter({ text: 'Bot Help Command', iconURL: 'https://i.imgur.com/wSTFkRM.png' });

return message.channel.send({ embeds: [helpEmbed] });
}

const name = args[0].toLowerCase();
const command = commands.get(name) || commands.find(c => c.aliases && c.aliases.includes(name));

if (!command) {
return message.reply('That\'s not a valid command!');
}

const commandEmbed = new EmbedBuilder()
.setColor('#0099ff')
.setTitle(`Command: ${command.name}`)
.addFields(
{ name: 'Description', value: command.description || 'No description available.' },
{ name: 'Usage', value: `\`${process.env.BOT_PREFIX}${command.name} ${command.usage || ''}\`` }
)
.setFooter({ text: 'Nexos Creator', iconURL: 'https://i.imgur.com/wSTFkRM.png' });

message.channel.send({ embeds: [commandEmbed] });
},
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions commands/utility/warn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('warn')
.setDescription('Warn a user')
.addUserOption(option => option.setName('user').setDescription('The user to warn').setRequired(true))
.addStringOption(option => option.setName('reason').setDescription('The reason for the warnning').setRequired(true)),
async execute(interaction) {
const user = interaction.options.getUser('user');
const reason = interaction.options.getString('reason');
await interaction.reply(`${user.tag} has been warned for: ${reason}`);
},
};
26 changes: 13 additions & 13 deletions events/guildMemberAdd.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { welcomeChannelId } = require('./../config/bot.json');
const { EmbedBuilder } = require('discord.js');

module.exports = {
name: 'guildMemberAdd',
Expand All @@ -7,20 +8,19 @@ module.exports = {
const channel = member.guild.channels.cache.get(welcomeChannelId);
// Check if the channel exists
if (!channel) return;
const welcomeMessage = `
🎉 Welcome to **${member.guild.name}**, ${member}!
We're excited to have you here. Please take a moment to check out the following channels:
- 📜 **rules**: Familiarize yourself with our server rules.
- 🎉 **announcements**: Stay updated with the latest news and events.
- 💬 **general**: Join the conversation with other members.
If you have any questions, feel free to ask in **#support** or reach out to the moderators.
Enjoy your stay! 😊
`;
// Create the welcome embed
const welcomeEmbed = new MessageEmbed()
.setColor('#0099ff') // Set the color of the embed
.setTitle('Welcome to the Server!')
.setDescription(`Hello ${member}, welcome to **${member.guild.name}**! We're glad to have you here.`)
.addField('Get Started', 'Here are a few tips to get you started:')
.addField('1. Read the Rules', 'Make sure to read the server rules in the #rules channel.')
.addField('2. Introduce Yourself', 'Feel free to introduce yourself in the #introductions channel.')
.addField('3. Have Fun!', 'Join the conversation in the various channels and have a great time!')
.setThumbnail(member.user.displayAvatarURL({ dynamic: true }))
.setFooter('We hope you enjoy your stay!', 'https://i.imgur.com/wSTFkRM.png');
// Send a message to the channel
channel.send(welcomeMessage);
channel.send({ embeds: [welcomeEmbed] });
// Optional: Send a direct message to the new member
member.send(`Hi ${member.displayName}, welcome to our Discord server! We are glad to have you here.`);
},
Expand Down
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('node:fs');
const path = require('node:path');
// const path = require('node:path');
const { Client, Collection, GatewayIntentBits } = require('discord.js');
const dotenv = require('dotenv'); //initializes dotenv
dotenv.config();
Expand All @@ -17,15 +17,15 @@ const client = new Client({
client.commands = new Collection();

// basic command
const BasiccommandFiles = fs.readdirSync('./commands/basics').filter(file => file.endsWith('.js'));
for (const file of BasiccommandFiles) {
const BasicCommandFiles = fs.readdirSync('./commands/basics').filter(file => file.endsWith('.js'));
for (const file of BasicCommandFiles) {
const command = require(`./commands/basics/${file}`);
client.commands.set(command.name, command);
}

// slash command
const SlashcommandFiles = fs.readdirSync('./commands/utility').filter(file => file.endsWith('.js'));
for (const file of SlashcommandFiles) {
const SlashCommandFiles = fs.readdirSync('./commands/utility').filter(file => file.endsWith('.js'));
for (const file of SlashCommandFiles) {
const command = require(`./commands/utility/${file}`);
client.commands.set(command.data.name, command);
}
Expand Down
33 changes: 33 additions & 0 deletions utils/rss-feed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const Parser = require('rss-parser');

const rssParser = new Parser();

// Array of RSS feed URLs to monitor
const rssFeeds = [
'https://example.com/feed/rss',
'https://anotherwebsite.com/rss.xml'
];

async function checkFeeds() {
try {
for (const feedUrl of rssFeeds) {
const feed = await rssParser.parseURL(feedUrl);
if (feed && feed.items && feed.items.length > 0) {
const latestItem = feed.items[0];
const message = `**New Post on ${feed.title}**\n${latestItem.title}\n${latestItem.link}`;
postToDiscord(message);
}
}
} catch (error) {
console.error('Error fetching or parsing RSS feed:', error.message);
}
}

function postToDiscord(content) {
const channel = client.channels.cache.get('your_channel_id_here'); // Replace with your channel ID
if (channel) {
channel.send(content);
} else {
console.error('Invalid channel ID or missing permissions');
}
}

0 comments on commit 43301af

Please sign in to comment.