Skip to content

Commit

Permalink
refactor: remove prefix commands
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperchupuDev committed Sep 2, 2022
1 parent e3a30c0 commit 058e1e7
Show file tree
Hide file tree
Showing 61 changed files with 1,356 additions and 1,354 deletions.
4 changes: 2 additions & 2 deletions changelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"features": [
{
"name": "Fully Implemented Slash Commands",
"value": "All commands are in Slash Commands too!"
"value": "The bot now fully uses Slash Commands!"
},
{
"name": "DMs Support",
"value": "You can now use (most) commands in DMs!"
},
{
"name": "No More Prefix Commands",
"value": "Old prefix commands are now deprecated and will be removed soon. Make sure to use Slash Commands!"
"value": "Old prefix commands have been removed. Make sure to use Slash Commands!"
},
{
"name": "Command Permissions v2",
Expand Down
13 changes: 8 additions & 5 deletions commands/bot/changelog.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const changelog = require('../../changelog.json');
const { SlashCommandBuilder } = require('@discordjs/builders');

module.exports = {
name: 'chanqeloq',
description: 'Check the latest version',
async execute(client, message) {
message.channel.send({
async execute(client, interaction) {
interaction.reply({
embeds: [{
title: 'Chanqeloq',
url: 'https://github.com/h-projects/gasbot/blob/master/CHANGELOG.md',
Expand All @@ -15,5 +14,9 @@ module.exports = {
fields: changelog.features
}]
});
}
},

data: new SlashCommandBuilder()
.setName('chanqeloq')
.setDescription('Check the latest version')
};
14 changes: 9 additions & 5 deletions commands/bot/credits.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const { SlashCommandBuilder } = require('@discordjs/builders');

module.exports = {
name: 'credits',
description: 'People who helped in the development',
async execute(client, message) {
async execute(client, interaction) {
const developers = (await Promise.all(client.config.developers.map(async id => (await client.users.fetch(id)).tag))).join('\n');
const specialThanksUsers = (await Promise.all(client.config.specialThanksUsers.map(async id => (await client.users.fetch(id)).tag))).join('\n');
message.channel.send({
interaction.reply({
embeds: [{
title: 'Credits',
fields: [
Expand All @@ -14,5 +14,9 @@ module.exports = {
color: client.config.color
}]
});
}
},

data: new SlashCommandBuilder()
.setName('credits')
.setDescription('People who helped in the development')
};
93 changes: 68 additions & 25 deletions commands/bot/detector.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,47 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
const { PermissionFlagsBits } = require('discord-api-types/v10');

module.exports = {
name: 'detector',
description: 'Manaqe the detection level',
permissions: ['MANAGE_MESSAGES'],
async execute(client, message) {
const level = client.db.prepare('SELECT level FROM guilds WHERE id = ?').get(message.guild.id)?.level ?? 1;
async execute(client, interaction) {
const input = interaction.options.getString('level');
const database = client.db.prepare('SELECT level FROM guilds WHERE id = ?').get(interaction.guildId);
const statement = database ? 'UPDATE guilds SET level = @level WHERE id = @id' : 'INSERT INTO guilds (id, level) VALUES (@id, @level)';
const levelNames = ['Low', 'Medium', 'Hiqh'];

message.channel.send({
let description;
let fields = null;

switch (input) {
case 'low':
description = 'Successfully set detection level to **Low**!';
client.db.prepare(statement).run({ id: interaction.guildId, level: 0 });
break;

case 'medium':
description = 'Successfully set detection level to **Medium**!';
client.db.prepare(statement).run({ id: interaction.guildId, level: 1 });
break;

case 'hiqh':
description = 'Successfully set detection level to **Hiqh**!';
client.db.prepare(statement).run({ id: interaction.guildId, level: 2 });
break;

default:
description = `Your current protection level: **${levelNames[database?.level ?? 1]}**`;
fields = [
{ name: 'Low', value: 'Detects messaqes that only consist of G' },
{ name: 'Medium', value: 'Detects G outside words' },
{ name: 'Hiqh', value: 'Detects a messaqe if it contains G' }
];
}

interaction.reply({
embeds: [{
title: 'G Detector Levels',
description: `Your current protection level: **${levelNames[level]}**`,
description,
color: client.config.color,
fields: [
{
name: 'Low',
value: 'Detects messaqes that only consist of G'
},
{
name: 'Medium',
value: 'Detects G outside words'
},
{
name: 'Hiqh',
value: 'Detects a messaqe if it contains G'
}
]
fields
}],
components: [{
type: 'ACTION_ROW',
Expand All @@ -33,22 +50,48 @@ module.exports = {
type: 'BUTTON',
style: 'SECONDARY',
label: 'Low',
customId: `detector:low:${message.author.id}`
customId: `detector:low:${interaction.user.id}`,
disabled: input === 'low'
},
{
type: 'BUTTON',
style: 'SECONDARY',
label: 'Medium',
customId: `detector:medium:${message.author.id}`
customId: `detector:medium:${interaction.user.id}`,
disabled: input === 'medium'
},
{
type: 'BUTTON',
style: 'SECONDARY',
label: 'Hiqh',
customId: `detector:hiqh:${message.author.id}`
customId: `detector:hiqh:${interaction.user.id}`,
disabled: input === 'hiqh'
}
]
}]
});
}
},

data: new SlashCommandBuilder()
.setName('detector')
.setDescription('Manaqe the detection level')
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages)
.setDMPermission(false)
.addStringOption(option => option
.setName('level')
.setDescription('The new detection level')
.setRequired(false)
.addChoices(
{
name: 'Low',
value: 'low'
}, {
name: 'Medium',
value: 'medium'
}, {
name: 'Hiqh',
value: 'hiqh'
}
)
)
};
51 changes: 34 additions & 17 deletions commands/bot/g-spy.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
module.exports = {
name: 'g-spy',
description: 'Mark a user as a g-spy',
permissions: ['MANAGE_ROLES'],
botPermissions: ['MANAGE_ROLES'],
async execute(client, message) {
const userId = /\d+/u.exec(message.content)?.toString();
const member = userId ? await message.guild.members.fetch(userId).catch(() => null) : null;
const { SlashCommandBuilder, ContextMenuCommandBuilder } = require('@discordjs/builders');
const { PermissionFlagsBits, ApplicationCommandType } = require('discord-api-types/v10');

module.exports = {
appPermissions: ['MANAGE_ROLES'],
async execute(client, interaction) {
const member = interaction.options.getMember('user');

if (!member || userId === message.author.id || member.user.bot) {
return message.channel.send({
if (!member || member.id === interaction.user.id || member.user.bot) {
return interaction.reply({
embeds: [{
title: 'Invalid User',
description: 'You need to mention a valid user!',
color: client.config.color
}]
}],
ephemeral: true
});
}

const role = message.guild.roles.cache.find(r => r.name === 'g-spy') ?? await message.guild.roles.create({
const role = interaction.guild.roles.cache.find(r => r.name === 'g-spy') ?? await interaction.guild.roles.create({
name: 'g-spy',
reason: 'Found a g-spy'
});

if (!role.editable) {
return message.channel.send({
return interaction.reply({
embeds: [{
title: 'Missinq Permissions',
description: `Make sure ${role} is lower than my hiqhest role`,
color: client.config.color
}]
}],
ephemeral: true
});
}

member.roles.add(role);
message.channel.send({
interaction.reply({
embeds: [{
title: 'Done',
description: `${member} was marked as a ${role}`,
Expand All @@ -46,9 +46,26 @@ module.exports = {
type: 'BUTTON',
style: 'SECONDARY',
label: 'Revert',
customId: `g-spy:${member.id}:${message.author.id}`
customId: `g-spy:${member.id}:${interaction.user.id}`
}]
}]
});
}
},

data: new SlashCommandBuilder()
.setName('g-spy')
.setDescription('Mark a user as a g-spy')
.setDefaultMemberPermissions(PermissionFlagsBits.ManageRoles)
.setDMPermission(false)
.addUserOption(option => option
.setName('user')
.setDescription('User to mark as g-spy')
.setRequired(true)
),

contextData: new ContextMenuCommandBuilder()
.setName('Mark as G Spy')
.setDefaultMemberPermissions(PermissionFlagsBits.ManageRoles)
.setDMPermission(false)
.setType(ApplicationCommandType.User)
};
44 changes: 0 additions & 44 deletions commands/bot/help.js

This file was deleted.

13 changes: 8 additions & 5 deletions commands/bot/info.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
const { stripIndents } = require('common-tags');
const { version } = require('discord.js');
const { version: botVersion } = require('../../package.json');

module.exports = {
name: 'info',
description: 'Display information about the bot',
async execute(client, message) {
async execute(client, interaction) {
const developers = (await Promise.all(client.config.developers.map(async id => (await client.users.fetch(id)).tag))).join('\n');
await client.application.fetch();
message.channel.send({
interaction.reply({
embeds: [{
title: 'Info',
color: client.config.color,
Expand Down Expand Up @@ -41,5 +40,9 @@ module.exports = {
}
}]
});
}
},

data: new SlashCommandBuilder()
.setName('info')
.setDescription('Display information about the bot')
};
14 changes: 9 additions & 5 deletions commands/bot/links.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const { SlashCommandBuilder } = require('@discordjs/builders');

module.exports = {
name: 'links',
description: 'Useful bot links',
async execute(client, message) {
async execute(client, interaction) {
const nog = '<:nog:676105350306594819>';
const gas = '<:gas:896370532751147028>';
const aytchSoftware = '<:AytchSoftware:720949593696894996>';

await client.application.fetch();

message.channel.send({
interaction.reply({
embeds: [{
title: 'Links',
fields: [
Expand All @@ -32,5 +32,9 @@ module.exports = {
color: client.config.color
}]
});
}
},

data: new SlashCommandBuilder()
.setName('links')
.setDescription('Useful bot links')
};
Loading

0 comments on commit 058e1e7

Please sign in to comment.