···1+MIT License
2+3+Copyright (c) 2024 isabelroses
4+5+Permission is hereby granted, free of charge, to any person obtaining a copy
6+of this software and associated documentation files (the "Software"), to deal
7+in the Software without restriction, including without limitation the rights
8+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+copies of the Software, and to permit persons to whom the Software is
10+furnished to do so, subject to the following conditions:
11+12+The above copyright notice and this permission notice shall be included in all
13+copies or substantial portions of the Software.
14+15+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+SOFTWARE.
+32
README.md
···00000000000000000000000000000000
···1+# Blahaj
2+3+<h1 align="center">
4+ <img src="assets/BigBlobhajHug.svg" width="128" height="128" /><br />
5+ Blåhaj
6+</h1>
7+8+Blahaj is a simple discord bot that is designed to do anything that you want it to do. It is written in JavaScript and uses the discord.js library.
9+10+## Installation
11+12+To install blahaj, you need to have node.js installed. You can download it from [here](https://nodejs.org/en/download/). Once you have node.js installed, you can install blahaj by running the following command:
13+14+Then navigate to the file and run the following command:
15+```bash
16+npm install
17+```
18+This will install all the dependencies that blahaj needs to run.
19+20+## Usage
21+22+To run blahaj
23+```bash
24+node src/index.js
25+```
26+27+28+## Thanks
29+30+Thanks to [discord.js](https://discord.js.org/#/) for making this bot possible.
31+32+Thanks to this [reddit post](https://www.reddit.com/r/BLAHAJ/comments/s91n8d/some_blahaj_emojis/) for the emojis.
···1+const { SlashCommandBuilder, PermissionsBitField } = require('discord.js');
2+3+module.exports = {
4+ data: new SlashCommandBuilder()
5+ .setName('ban')
6+ .setDescription('Bans a user')
7+ .setDefaultMemberPermissions(PermissionsBitField.Flags.BanMembers)
8+ .addUserOption(option => option.setName('target').setDescription('The user to ban').setRequired(true))
9+ .addStringOption(option => option.setName('reason').setDescription('The reason for the ban').setRequired(false)),
10+ async execute(interaction) {
11+ const user = interaction.options.getUser('target');
12+ const member = await interaction.guild.members.fetch(user.id).catch(console.error);
13+ let reason = interaction.options.getString('reason');
14+ if (!reason) reason = 'No reason provided';
15+16+ if (!interaction.member.permissions.has(PermissionsBitField.Flags.BanMembers)) return await interaction.reply({ content: 'You do not have permission to ban this user', ephemeral: true })
17+ if (!member.kickable) return await interaction.reply({ content: 'This user cannot be banned', ephemeral: true })
18+ if (!member) return await interaction.reply({ content: `User ${user.tag} is not in this server`, ephemeral: true })
19+ if (interaction.member.id === user.id) return await interaction.reply({ content: 'You cannot ban yourself', ephemeral: true })
20+ if (member.permissions.has(PermissionsBitField.Flags.Administrator)) return await interaction.reply({ content: 'You cannot ban this user', ephemeral: true })
21+22+ user.send(`You have been banned from ${interaction.guild.name} for ${reason}`).catch(console.log("Dm's are disabled for this user"));
23+ await member.ban({
24+ deleteMessageSeconds: 60 * 60 * 24 * 7,
25+ reason: reason,
26+ }).catch(console.error);
27+ await interaction.reply({
28+ content: `Banned ${user.tag} for ${reason}`,
29+ ephemeral: true
30+ })
31+ }
32+};
+29
src/commands/moderation/kick.js
···00000000000000000000000000000
···1+const { SlashCommandBuilder, PermissionsBitField } = require('discord.js');
2+3+module.exports = {
4+ data: new SlashCommandBuilder()
5+ .setName('kick')
6+ .setDescription('Kicks a user')
7+ .setDefaultMemberPermissions(PermissionsBitField.Flags.KickMembers)
8+ .addUserOption(option => option.setName('target').setDescription('The user to kick').setRequired(true))
9+ .addStringOption(option => option.setName('reason').setDescription('The reason for the kick').setRequired(false)),
10+ async execute(interaction) {
11+ const user = interaction.options.getUser('target');
12+ const member = await interaction.guild.members.fetch(user.id).catch(console.error);
13+ let reason = interaction.options.getString('reason');
14+ if (!reason) reason = 'No reason provided';
15+16+ if (!interaction.member.permissions.has(PermissionsBitField.Flags.KickMembers)) return await interaction.reply({ content: 'You do not have permission to kick this user', ephemeral: true })
17+ if (!member.kickable) return await interaction.reply({ content: 'This user cannot be kicked', ephemeral: true })
18+ if (!member) return await interaction.reply({ content: `User ${user.tag} is not in this server`, ephemeral: true })
19+ if (interaction.member.id === user.id) return await interaction.reply({ content: 'You cannot kick yourself', ephemeral: true })
20+ if (member.permissions.has(PermissionsBitField.Flags.Administrator)) return await interaction.reply({ content: 'You cannot kick this user', ephemeral: true })
21+22+ user.send(`You have been kicked from ${interaction.guild.name} for ${reason}`).catch(console.error);
23+ await member.kick(`You have been kicked from ${interaction.guild.name} for ${reason}`).catch(console.log("Dm's are disabled for this user"));
24+ await interaction.reply({
25+ content: `Kicked ${user.tag} for ${reason}`,
26+ ephemeral: true
27+ })
28+ }
29+};
+27
src/commands/moderation/purge.js
···000000000000000000000000000
···1+const { SlashCommandBuilder } = require('@discordjs/builders');
2+const { PermissionsBitField } = require('discord.js');
3+4+module.exports = {
5+ data: new SlashCommandBuilder()
6+ .setName('purge')
7+ .setDescription('Deletes messages.')
8+ .setDefaultMemberPermissions(PermissionsBitField.Flags.ManageMessages)
9+ .addIntegerOption(option =>
10+ option.setName('amount')
11+ .setMinValue(1)
12+ .setMaxValue(100)
13+ .setDescription('The amount of messages to delete.')
14+ .setRequired(true)),
15+ async execute(interaction) {
16+ if (!interaction.member.permissions.has(PermissionsBitField.Flags.ManageMessages)) return await interaction.reply({ content: 'You do not have permission to purge messages', ephemeral: true })
17+18+ let amount = interaction.options.getInteger('amount');
19+20+ await interaction.channel.bulkDelete(amount).catch(err => {
21+ console.error(err);
22+ interaction.reply({ content: 'There was an error trying to purge messages in this channel!', ephemeral: true });
23+ });
24+25+ await interaction.reply({ content: `Successfully deleted ${amount} messages.`, ephemeral: true });
26+ }
27+};
+41
src/commands/moderation/timeout.js
···00000000000000000000000000000000000000000
···1+const { SlashCommandBuilder, PermissionsBitField } = require('discord.js');
2+3+module.exports = {
4+ data: new SlashCommandBuilder()
5+ .setName('timeout')
6+ .setDescription('Times out a user')
7+ .setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers)
8+ .addUserOption(option => option.setName('target').setDescription('The user to time out').setRequired(true))
9+ .addStringOption(option => option.setName('time').setDescription('The duration to time the user out').setRequired(true).addChoices(
10+ { name: '60 seconds', value: '60' },
11+ { name: '5 minutes', value: '300' },
12+ { name: '10 minutes', value: '600' },
13+ { name: '30 minutes', value: '1800' },
14+ { name: '1 hour', value: '3600' },
15+ { name: '12 hours', value: '43200' },
16+ { name: '1 day', value: '86400' },
17+ { name: '1 week', value: '604800' },
18+ { name: '1 month', value: '2629743' }
19+ ))
20+ .addStringOption(option => option.setName('reason').setDescription('The reason for the timeout').setRequired(false)),
21+ async execute(interaction) {
22+ const user = interaction.options.getUser('target');
23+ const member = await interaction.guild.members.fetch(user.id).catch(console.error);
24+ let reason = interaction.options.getString('reason');
25+ let time = interaction.options.getString('time');
26+ if (!time) time = '60';
27+ if (!reason) reason = 'No reason provided';
28+29+ if (!interaction.member.permissions.has(PermissionsBitField.Flags.ModerateMembers)) return await interaction.reply({ content: 'You do not have permission to timeout this user', ephemeral: true })
30+ if (!member.kickable) return await interaction.reply({ content: 'This user cannot be timed out', ephemeral: true })
31+ if (!member) return await interaction.reply({ content: `User ${user.tag} is not in this server`, ephemeral: true })
32+ if (interaction.member.id === user.id) return await interaction.reply({ content: 'You cannot timeout yourself', ephemeral: true })
33+ if (member.permissions.has(PermissionsBitField.Flags.Administrator)) return await interaction.reply({ content: 'You cannot timeout this user', ephemeral: true })
34+35+ await member.timeout(time * 1000, reason).catch(console.error);
36+ await interaction.reply({
37+ content: `Timed out ${user.tag} for ${time} seconds for ${reason}`,
38+ ephemeral: true
39+ })
40+ }
41+};
+28
src/commands/moderation/unban.js
···0000000000000000000000000000
···1+const { SlashCommandBuilder, PermissionsBitField } = require('discord.js');
2+3+module.exports = {
4+ data: new SlashCommandBuilder()
5+ .setName('unban')
6+ .setDescription('Unbans a user')
7+ .setDefaultMemberPermissions(PermissionsBitField.Flags.BanMembers)
8+ .addUserOption(option => option.setName('target').setDescription('The user to unban').setRequired(true)),
9+ async execute(interaction, client) {
10+ const userid = interaction.options.getUser('target');
11+12+ if (!interaction.member.permissions.has(PermissionsBitField.Flags.BanMembers)) return await interaction.reply({ content: 'You do not have permission to unbanned this user', ephemeral: true })
13+ if (!member.kickable) return await interaction.reply({ content: 'This user cannot be unbanned out', ephemeral: true })
14+ if (!member) return await interaction.reply({ content: `User ${user.tag} is not in this server`, ephemeral: true })
15+ if (interaction.member.id === userid) return await interaction.reply({ content: 'You cannot unbanned yourself', ephemeral: true })
16+ if (member.permissions.has(PermissionsBitField.Flags.Administrator)) return await interaction.reply({ content: 'You cannot unbanned this user', ephemeral: true })
17+18+ await interactions.guild.ban.fetch().then(async bans => {
19+ if (bans.size == 0) return await interaction.reply({ content: 'There are no banned users in this server', ephemeral: true });
20+ let bUser = bans.find(b => b.user.id == userid);
21+ if (!bUser) return await interaction.reply({ content: 'This user is not banned', ephemeral: true });
22+23+ await interaction.guild.bans.remove(userid).catch(err => {
24+ return interaction.reply({ content: 'There was an error unbanning this user', ephemeral: true });
25+ });
26+ });
27+ }
28+};
+25
src/commands/moderation/untimeout.js
···0000000000000000000000000
···1+const { SlashCommandBuilder, PermissionsBitField } = require('discord.js');
2+3+module.exports = {
4+ data: new SlashCommandBuilder()
5+ .setName('untimeout')
6+ .setDescription('Untimes out a user')
7+ .setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers)
8+ .addUserOption(option => option.setName('target').setDescription('The user to untimeout').setRequired(true)),
9+ async execute(interaction) {
10+ const user = interaction.options.getUser('target');
11+ const member = await interaction.guild.members.fetch(user.id).catch(console.error);
12+13+ if (!interaction.member.permissions.has(PermissionsBitField.Flags.ModerateMembers)) return await interaction.reply({ content: 'You do not have permission to untimeout this user', ephemeral: true })
14+ if (!member.isTimeout) return await interaction.reply({ content: `User ${user.tag} is not timed out`, ephemeral: true })
15+ if (!member) return await interaction.reply({ content: `User ${user.tag} is not in this server`, ephemeral: true })
16+ if (interaction.member.id === user.id) return await interaction.reply({ content: 'You cannot untimeout yourself', ephemeral: true })
17+ if (member.permissions.has(PermissionsBitField.Flags.Administrator)) return await interaction.reply({ content: 'You cannot untimeout this user', ephemeral: true })
18+19+ await member.timeout(null).catch(console.error);
20+ await interaction.reply({
21+ content: `Untimed out ${user.tag}`,
22+ ephemeral: true
23+ })
24+ }
25+};