Skip to content
This repository was archived by the owner on Jan 25, 2026. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions bauerbot.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const Discord = require('discord.js');
const fs = require('fs');
const client = new Discord.Client();
const Discord = require('discord.js'),
fs = require('fs'),
client = new Discord.Client();

const prefix = 'b!';

client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}

Expand All @@ -18,18 +18,16 @@ client.on('ready', () => {
client.on('message', message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;

const args = message.content.slice(prefix.length).split(/ +/);
const commandName = args.shift().toLowerCase();
const command = client.commands.get(commandName)
|| client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
const args = message.content.slice(prefix.length).split(/ +/),
commandName = args.shift().toLowerCase(),
command = client.commands.get(commandName) || client.commands.find(cmd => cmd?.aliases?.includes(commandName)); //Only works with Node.js v14+

if (!command) return;


if(message.guild !== null) {
const admin = message.member.hasPermission("ADMINISTRATOR");
if (command.admin && !message.member.hasPermission("ADMINISTRATOR")) {
return message.reply('Permissions required to execute this command');
return message.reply('Permissions required to execute this command'); //???
}
}

Expand Down Expand Up @@ -64,7 +62,7 @@ client.on('message', message => {
}
const responseName = message.content.toLowerCase();
const response = client.responses.get(responseName)
|| client.responses.find(re => re.aliases && re.aliases.includes(responseName));
|| client.responses.find(re => re?.aliases?.includes(responseName)); //Again, optional chaining only work with Node v14+

if (!response) return;
response.execute(message);
Expand All @@ -74,9 +72,9 @@ client.on('message', message => {
client.on('message', message => {
const echo = require('./responses/echo.json');
if (!echo) return;
if( echo.some(word => message.content.toLowerCase() == word) && !message.author.bot) {
message.channel.send(message.content);
}
if( echo.some(word => message.content.toLowerCase() == word) && !message.author.bot) {
message.channel.send(message.content);
}
});

client.login(process.env.TOKEN);