Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperchupuDev committed Aug 26, 2021
1 parent 5cee802 commit f02fe56
Show file tree
Hide file tree
Showing 19 changed files with 145 additions and 180 deletions.
22 changes: 10 additions & 12 deletions commands/bot/detector.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
module.exports = {
name: 'detector',
description: 'Check the detection level',
description: 'Check the detection level',
permissions: 'MANAGE_MESSAGES',

async execute(client, message, args) {


async execute(client, message) {
const buttons = [
{
type: 'BUTTON',
style: 'SECONDARY',
label: 'Low',
custom_id: `detector:low:${message.author.id}`,
customId: `detector:low:${message.author.id}`
},
{
type: 'BUTTON',
style: 'SECONDARY',
label: 'Medium',
custom_id: `detector:medium:${message.author.id}`,
customId: `detector:medium:${message.author.id}`
},
{
type: 'BUTTON',
style: 'SECONDARY',
label: 'Hiqh',
custom_id: `detector:hiqh:${message.author.id}`,
customId: `detector:hiqh:${message.author.id}`
}
];
message.channel.send({

message.channel.send({
embeds: [{
title: 'G Detector Levels',
description: 'Your current protection level: **Low**',
Expand All @@ -51,6 +50,5 @@ module.exports = {
components: buttons
}]
});

}
}
}
};
30 changes: 14 additions & 16 deletions commands/bot/g-spy.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module.exports = {
name: 'g-spy',
description: 'Mark an user as a g-spy',
description: 'Mark an user as a g-spy',
permissions: ['MANAGE_MESSAGES', 'MANAGE_ROLES'],
async execute(client, message, args) {
const userId = /\d+/.exec(message.content)?.toString();

async execute(client, message) {
const userId = /\d+/u.exec(message.content)?.toString();
const member = userId ? await message.guild.members.fetch(userId).catch(() => null) : null;
if (!member || userId == message.author.id || userId == client.user.id) {


if (!member || userId === message.author.id || userId === client.user.id) {
return message.channel.send({
embeds: [{
title: 'Invalid User',
Expand All @@ -17,13 +17,13 @@ module.exports = {
}]
});
}
let role = message.guild.roles.cache.find(role => role.name == 'g-spy') ?? await message.guild.roles.create({

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

member.roles.add(role);
message.channel.send({
embeds: [{
title: 'Done',
Expand All @@ -36,11 +36,9 @@ module.exports = {
type: 'BUTTON',
style: 'SECONDARY',
label: 'Revert',
custom_id: `g-spy:${member.id}:${message.author.id}`,
customId: `g-spy:${member.id}:${message.author.id}`
}]
}]
});

}

}
};
10 changes: 5 additions & 5 deletions commands/bot/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@ module.exports = {
description: 'Views all commands in the bot',
hidden: true,

async execute(client, message, args) {
async execute(client, message) {
const buttons = [
{
type: 'BUTTON',
style: 'SECONDARY',
label: 'Bot',
custom_id: `help:bot:${message.author.id}`,
customId: `help:bot:${message.author.id}`,
emoji: '🤖'
},
{
type: 'BUTTON',
style: 'SECONDARY',
label: 'Fun',
custom_id: `help:fun:${message.author.id}`,
customId: `help:fun:${message.author.id}`,
emoji: '🥳'
}
];

client.config.owners.includes(message.author.id) && buttons.push({
type: 'BUTTON',
style: 'SECONDARY',
label: 'Dev',
custom_id: `help:dev:${message.author.id}`,
customId: `help:dev:${message.author.id}`,
emoji: '855104541967384616'
});

Expand Down
14 changes: 6 additions & 8 deletions commands/bot/ping.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
module.exports = {
name: 'pinq',
description: 'Pinq of G.A.S Bot',

async execute(client, message, args) {

message.channel.send({
description: 'Pinq of G.A.S Bot',

async execute(client, message) {
message.channel.send({
embeds: [{
color: client.config.color,
description: `**Ponq!** ${client.ws.ping}ms`
}]
});

}
}
}
};
9 changes: 5 additions & 4 deletions commands/dev/eval.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
name: "eval",
description: "Evaluate code inside G.A.S Bot",
name: 'eval',
description: 'Evaluate code inside G.A.S Bot',

async execute(client, message, args) {
if (client.config.owners.includes(message.author.id)) {
Expand Down Expand Up @@ -34,15 +34,16 @@ module.exports = {
if (client.config.owners.includes(message.author.id)) {
let evaled;
try {
evaled = eval(args.join(" "));
evaled = eval(args.join(' '));
} catch (e) {
evaled = e;
}
return message.channel.send({
embeds: [
{
color: client.config.color,
description: `\`\`\`js\n${evaled}\`\`\`` // should we replace it to client.disc.Formatters.codeBlock('js', evaled.toString())? its cleaner
description: `\`\`\`js\n${evaled}\`\`\``
// should we replace it to client.disc.Formatters.codeBlock('js', evaled.toString())? its cleaner
}
]
});
Expand Down
27 changes: 11 additions & 16 deletions events/interactionCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,27 @@ module.exports = {
name: 'interactionCreate',
once: false,
async execute(interaction, client) {

switch(interaction.type) {

switch (interaction.type) {
case 'APPLICATION_COMMAND':
const name = interaction.commandName
const command = client.interactions.commands.get(name) ?? client.interactions.commands.find(command => name == command.contextMenu)
const name = interaction.commandName;
const command = client.interactions.commands.get(name) ?? client.interactions.commands.find(cmd => name === cmd.contextMenu);

if (!command) return;
return command.execute(client, interaction);
command.execute(client, interaction);
break;


case 'MESSAGE_COMPONENT':

[interaction.name, interaction.value, interaction.author] = interaction.customId.split(':');
if (!client.interactions.components.has(interaction.name) || interaction.author != interaction.user.id) {

if (!client.interactions.components.has(interaction.name) || interaction.author !== interaction.user.id) {
return interaction.deferUpdate();
}

client.interactions.components.get(interaction.name).execute(client, interaction);

break;

}

}

};
7 changes: 3 additions & 4 deletions events/messageCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ module.exports = {
const array = message.content.replace(client.prefix, '').split(' ');
const args = array.slice(1);
const [ command ] = array;
const exceptions = message.author.bot || message.author.system || message.type !== 'DEFAULT' || !message.content

const exceptions = message.author.bot || message.author.system || message.type !== 'DEFAULT' || !message.content;
if (exceptions) return;

if (!client.commands.has(command) || !message.content.startsWith(client.prefix)) return;
if (!client.commands.has(command) || !message.content.startsWith(client.prefix)) return;
client.commands.get(command).execute(client, message, args);

}
};
10 changes: 5 additions & 5 deletions events/ready.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
name: 'ready',
once: true,
async execute(client) {
console.log('Ready!');
},
name: 'ready',
once: true,
async execute() {
console.log('Ready!');
}
};
3 changes: 1 addition & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ client.config = require('./config.json');
client.prefix = client.config.prefix;



const loaders = readdirSync('./loaders').filter(file => file.endsWith('.js'));

loaders.forEach(file => {
require(`./loaders/${file}`)(client);
});


process.on("unhandledRejection", console.error);
process.on('unhandledRejection', console.error);
client.login(process.env.DISCORD_TOKEN);
37 changes: 16 additions & 21 deletions interactions/commands/detector.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,57 @@
module.exports = {
name: 'detector',

async execute(client, interaction) {

const level = interaction.options.getString('level')
const level = interaction.options.getString('level');
let description;
let fields = null;

switch (level) {

case 'low':
description = 'Successfully set detection level to **Low**!';
break;

case 'medium':
description = 'Successfully set detection level to **Medium**!';
break;

case 'hiqh':
description = 'Successfully set detection level to **Hiqh**!';
break;

default:
description = 'Your current protection level: **Low**';
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' }
];

}

const buttons = [
{
type: 'BUTTON',
style: 'SECONDARY',
label: 'Low',
custom_id: `detector:low:${interaction.user.id}`,
disabled: level == 'low'
customId: `detector:low:${interaction.user.id}`,
disabled: level === 'low'
},
{
type: 'BUTTON',
style: 'SECONDARY',
label: 'Medium',
custom_id: `detector:medium:${interaction.user.id}`,
disabled: level == 'medium'
customId: `detector:medium:${interaction.user.id}`,
disabled: level === 'medium'
},
{
type: 'BUTTON',
style: 'SECONDARY',
label: 'Hiqh',
custom_id: `detector:hiqh:${interaction.user.id}`,
disabled: level == 'hiqh'
customId: `detector:hiqh:${interaction.user.id}`,
disabled: level === 'hiqh'
}
];
interaction.reply({

interaction.reply({
embeds: [{
title: 'G Detector Levels',
description,
Expand All @@ -67,6 +63,5 @@ module.exports = {
components: buttons
}]
});

}
}
}
};
Loading

0 comments on commit f02fe56

Please sign in to comment.