Skip to content

Commit

Permalink
Merge pull request #66 from clienterrverse/es6-rewrite
Browse files Browse the repository at this point in the history
prifix command
  • Loading branch information
GrishMahat authored Jul 27, 2024
2 parents e667301 + c222962 commit 5e6e48b
Show file tree
Hide file tree
Showing 53 changed files with 1,493 additions and 353 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default {
nsfwMode: false,
testMode: false,
devOnly: false,
category: 'Admin',

run: async (client, interaction) => {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export default {
PermissionFlagsBits.ManageChannels,
PermissionFlagsBits.ManageRoles,
],
category: 'Admin',

run: async (client, interaction) => {
const subcommand = interaction.options.getSubcommand();
Expand Down
2 changes: 2 additions & 0 deletions src/commands/misc/purge.js → src/commands/admin/purge.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export default {
nwfwMode: false,
testMode: false,
devOnly: false,
category: 'Admin',
prefix: true,

run: async (client, interaction) => {
const amount = interaction.options.getInteger('amount');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default {
userPermissions: [PermissionsBitField.ADMINISTRATOR],
botPermissions: [PermissionsBitField.ManageRoles],
cooldown: 5,
category: 'Admin',

run: async (client, interaction) => {
await interaction.deferReply({ ephemeral: true });
Expand Down
2 changes: 2 additions & 0 deletions src/commands/developer/createitem.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export default {
.toJSON(),
userPermissions: [],
botPermissions: [],
category: 'Devloper',

cooldown: 10,
nsfwMode: false,
testMode: false,
Expand Down
1 change: 1 addition & 0 deletions src/commands/developer/delitem.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default {
.toJSON(),
userPermissions: [],
botPermissions: [],
category: 'Devloper',
cooldown: 10,
nsfwMode: false,
testMode: false,
Expand Down
1 change: 1 addition & 0 deletions src/commands/developer/dm.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export default {
nwfwMode: false,
testMode: false,
devOnly: true,
category: 'Devloper',

run: async (client, interaction) => {
const subcommand = interaction.options.getSubcommand();
Expand Down
1 change: 1 addition & 0 deletions src/commands/developer/eco.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export default {
nsfwMode: false,
testMode: false,
devOnly: true,
category: 'Devloper',

run: async (client, interaction) => {
const subcommand = interaction.options.getSubcommand();
Expand Down
1 change: 1 addition & 0 deletions src/commands/developer/servers.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export default {
nsfwMode: false,
testMode: false,
devOnly: true,
category: 'Devloper',

run: async (client, interaction) => {
await interaction.deferReply({ ephemeral: true });
Expand Down
107 changes: 107 additions & 0 deletions src/commands/developer/setPrefix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import { UserPrefix } from '../../schemas/prefix.js';
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';

const DISALLOWED_PREFIXES = [
'/',
'\\',
'@',
'#',
'$',
'&',
'(',
')',
'{',
'}',
'[',
']',
];

export default {
data: new SlashCommandBuilder()
.setName('setprefix')
.setDescription('Set a prefix for a user or remove it (dev only)')
.addUserOption((option) =>
option
.setName('user')
.setDescription('The user to set the prefix for')
.setRequired(true)
)
.addStringOption((option) =>
option
.setName('prefix')
.setDescription('The new prefix to set (use "noprefix" to remove)')
.setRequired(true)
),
userPermissions: [],
botPermissions: [],
category: 'Misc',
cooldown: 5,
nsfwMode: false,
testMode: false,
devOnly: true,
category: 'Devloper',

run: async (client, interaction) => {
try {
const targetUser = interaction.options.getUser('user');
const newPrefix = interaction.options.getString('prefix');

if (!targetUser) {
return interaction.reply({
content: 'Please provide a valid user.',
ephemeral: true,
});
}

await updatePrefix(interaction, targetUser, newPrefix);
} catch (error) {
console.error('Error in setprefix command:', error);
await interaction.reply({
content:
'An error occurred while processing the command. Please try again later.',
ephemeral: true,
});
}
},
};

async function updatePrefix(interaction, targetUser, newPrefix) {
if (DISALLOWED_PREFIXES.includes(newPrefix) && newPrefix !== 'noprefix') {
return interaction.reply({
content: `The prefix "${newPrefix}" is not allowed as it may conflict with Discord or bot functionality.`,
ephemeral: true,
});
}

const finalPrefix = newPrefix === 'noprefix' ? '' : newPrefix;
let updateData;
let responseMessage;

if (newPrefix === 'noprefix') {
updateData = { exemptFromPrefix: true, prefix: '' };
responseMessage = `Prefix for ${targetUser.tag} has been removed and they are now exempt from using a prefix.`;
} else {
updateData = { exemptFromPrefix: false, prefix: finalPrefix };
responseMessage = `Prefix for ${targetUser.tag} has been updated to \`${finalPrefix}\`.`;
}

try {
await UserPrefix.findOneAndUpdate(
{ userId: targetUser.id },
{ $set: { ...updateData, userId: targetUser.id } },
{ upsert: true, new: true, runValidators: true }
);

await interaction.reply({
content: responseMessage,
ephemeral: true,
});
} catch (error) {
console.error('Error updating prefix:', error);
await interaction.reply({
content:
'An error occurred while updating the prefix. Please try again later.',
ephemeral: true,
});
}
}
1 change: 1 addition & 0 deletions src/commands/economy/balance.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default {
testMode: false,
devOnly: false,
dmAllowed: true,
category: 'economy',

run: async (client, interaction) => {
const userId = interaction.user.id;
Expand Down
1 change: 1 addition & 0 deletions src/commands/economy/bank.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default {
nwfwMode: false,
testMode: false,
devOnly: false,
category: 'economy',

run: async (client, interaction) => {
try {
Expand Down
1 change: 1 addition & 0 deletions src/commands/economy/beg.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default {
nsfwMode: false,
testMode: false,
devOnly: false,
category: 'economy',

run: async (client, interaction) => {
const userId = interaction.user.id;
Expand Down
1 change: 1 addition & 0 deletions src/commands/economy/coinflip.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default {
nsfwMode: false,
testMode: false,
devOnly: false,
category: 'economy',

run: async (client, interaction) => {
const userId = interaction.user.id;
Expand Down
1 change: 1 addition & 0 deletions src/commands/economy/crime.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default {
nsfwMode: false,
testMode: false,
devOnly: false,
category: 'economy',

run: async (client, interaction) => {
const userId = interaction.user.id;
Expand Down
1 change: 1 addition & 0 deletions src/commands/economy/daily.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default {
nsfwMode: false,
testMode: false,
devOnly: false,
category: 'economy',

run: async (client, interaction) => {
const userId = interaction.user.id;
Expand Down
1 change: 1 addition & 0 deletions src/commands/economy/deposit.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default {
nwfwMode: false,
testMode: false,
devOnly: false,
category: 'economy',

run: async (client, interaction) => {
const userId = interaction.user.id;
Expand Down
1 change: 1 addition & 0 deletions src/commands/economy/hourly.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default {
nwfwMode: false,
testMode: false,
devOnly: false,
category: 'economy',

run: async (client, interaction) => {
const userId = interaction.user.id;
Expand Down
1 change: 1 addition & 0 deletions src/commands/economy/inventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default {
nsfwMode: false,
testMode: false,
devOnly: false,
category: 'economy',

run: async (client, interaction) => {
const userId = interaction.user.id;
Expand Down
1 change: 1 addition & 0 deletions src/commands/economy/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default {
nsfwMode: false,
testMode: false,
devOnly: false,
category: 'economy',

run: async (client, interaction) => {
// Fetch all items from the database
Expand Down
1 change: 1 addition & 0 deletions src/commands/economy/leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default {
nsfwMode: false,
testMode: false,
devOnly: false,
category: 'economy',

run: async (client, interaction) => {
// Defer the interaction
Expand Down
2 changes: 2 additions & 0 deletions src/commands/economy/shop.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export default {
nsfwMode: false,
testMode: false,
devOnly: false,
category: 'economy',

run: async (client, interaction) => {
try {
const items = await Item.find().lean();
Expand Down
1 change: 1 addition & 0 deletions src/commands/economy/slots.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default {
nsfwMode: false,
testMode: false,
devOnly: false,
category: 'economy',

run: async (client, interaction) => {
const userId = interaction.user.id;
Expand Down
1 change: 1 addition & 0 deletions src/commands/economy/weekly.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default {
nsfwMode: false,
testMode: false,
devOnly: false,
category: 'economy',

run: async (client, interaction) => {
const userId = interaction.user.id;
Expand Down
1 change: 1 addition & 0 deletions src/commands/economy/withdraw.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default {
nsfwMode: false,
testMode: false,
devOnly: false,
category: 'economy',

run: async (client, interaction) => {
const userId = interaction.user.id;
Expand Down
2 changes: 2 additions & 0 deletions src/commands/image/cat.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ export default {
.setDescription('send random cat img')

.toJSON(),
category: 'Image',
nwfwMode: false,
testMode: false,
devOnly: false,
prefix: true,

userPermissionsBitField: [],
bot: [],
Expand Down
2 changes: 2 additions & 0 deletions src/commands/image/dog.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ export default {
.setName('dog')
.setDescription('send random dog image')
.toJSON(),
category: 'Image',
nwfwMode: false,
testMode: false,
devOnly: false,
prefix: true,

userPermissionsBitField: [],
bot: [],
Expand Down
1 change: 1 addition & 0 deletions src/commands/image/magik.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default {
cooldown: 10,
nsfwMode: false,
testMode: false,
category: 'Image',
devOnly: false,
userPermissionsBitField: [],
bot: [],
Expand Down
2 changes: 2 additions & 0 deletions src/commands/misc/avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ export default {

userPermissions: [],
botPermissions: [],
category: 'Misc',
cooldown: 5,
deleted: false,
nwfwMode: false,
testMode: false,
devOnly: false,
prefix: true,

run: async (client, interaction) => {
try {
Expand Down
3 changes: 3 additions & 0 deletions src/commands/misc/fact.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ export default {

userPermissionsBitField: [],
bot: [],
category: 'Misc',
cooldown: 19, // Cooldown of 5 seconds
nwfwMode: false,
testMode: false,
devOnly: false,
prefix: true,

run: async (client, interaction) => {
try {
const res = await axios.get(
Expand Down
1 change: 1 addition & 0 deletions src/commands/misc/guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default {
cooldown: 5,
userPermissionsBitField: [],
bot: [],
category: 'Misc',

run: async (client, interaction) => {
if (interaction.options.getSubcommand() === 'join') {
Expand Down
Loading

0 comments on commit 5e6e48b

Please sign in to comment.