Skip to content

Commit

Permalink
Merge pull request AlexzanderFlores#181 from AlexzanderFlores/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
AlexzanderFlores authored Oct 11, 2021
2 parents 43a2b65 + 3ce04dd commit aa2480c
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 26 deletions.
43 changes: 33 additions & 10 deletions dist/commands/slash.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,53 @@ module.exports = {
}
return `Slash command with the ID "${text}" has been deleted. This may take up to 1 hour to be seen on all servers using your bot.`;
}
let allSlashCommands = '';
let counter = 0;
let allSlashCommands = [];
if (global.size) {
global.forEach((cmd) => {
allSlashCommands += `${cmd.name}: ${cmd.id}\n`;
const newString = `${cmd?.name}: ${cmd?.id}\n`;
if (!allSlashCommands[counter]) {
allSlashCommands[counter] = '';
}
if (allSlashCommands[counter].length + newString.length < 1024) {
allSlashCommands[counter] += newString;
}
else {
allSlashCommands[++counter] += newString;
}
});
}
else {
allSlashCommands = 'None';
allSlashCommands.push('None');
}
const embed = new discord_js_1.MessageEmbed().addField('How to delete a slash command:', `${instance.getPrefix(guild)}slash <command-id>`);
for (let a = 0; a < allSlashCommands.length; ++a) {
embed.addField(`Global slash commands:${a === 0 ? '' : ' (Continued)'}`, allSlashCommands[a]);
}
const embed = new discord_js_1.MessageEmbed()
.addField('How to delete a slash command:', `${instance.getPrefix(guild)}slash <command-id>`)
.addField('List of global slash commands:', allSlashCommands);
if (guild) {
const guildOnly = await slashCommands.get(guild.id);
let guildOnlyCommands = '';
counter = 0;
let guildOnlyCommands = [];
if (guildOnly.size) {
guildOnly.forEach((cmd) => {
guildOnlyCommands += `${cmd.name}: ${cmd.id}\n`;
const newString = `${cmd.name}: ${cmd.id}\n`;
if (!guildOnlyCommands[counter]) {
guildOnlyCommands[counter] = '';
}
if (guildOnlyCommands[counter].length + newString.length < 1024) {
guildOnlyCommands[counter] += newString;
}
else {
guildOnlyCommands[++counter] += newString;
}
});
}
else {
guildOnlyCommands = 'None';
guildOnlyCommands[0] = 'None';
}
for (let a = 0; a < guildOnlyCommands.length; ++a) {
embed.addField(`Guild slash commands:${a === 0 ? '' : ' (Continued)'}`, guildOnlyCommands[a]);
}
embed.addField('List of slash commands for this guild:', guildOnlyCommands);
}
if (instance.color) {
embed.setColor(instance.color);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wokcommands",
"version": "1.5.1",
"version": "1.5.2",
"main": "dist/index.js",
"typings": "./typings.d.ts",
"scripts": {
Expand Down
59 changes: 44 additions & 15 deletions src/commands/slash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,40 +44,69 @@ export = {
return `Slash command with the ID "${text}" has been deleted. This may take up to 1 hour to be seen on all servers using your bot.`
}

let allSlashCommands = ''
let counter = 0
let allSlashCommands: string[] = []

if (global.size) {
global.forEach((cmd: ApplicationCommand) => {
allSlashCommands += `${cmd.name}: ${cmd.id}\n`
const newString = `${cmd?.name}: ${cmd?.id}\n`

if (!allSlashCommands[counter]) {
allSlashCommands[counter] = ''
}

if (allSlashCommands[counter].length + newString.length < 1024) {
allSlashCommands[counter] += newString
} else {
allSlashCommands[++counter] += newString
}
})
} else {
allSlashCommands = 'None'
allSlashCommands.push('None')
}

const embed = new MessageEmbed()
.addField(
'How to delete a slash command:',
`${instance.getPrefix(guild)}slash <command-id>`
const embed = new MessageEmbed().addField(
'How to delete a slash command:',
`${instance.getPrefix(guild)}slash <command-id>`
)

for (let a = 0; a < allSlashCommands.length; ++a) {
embed.addField(
`Global slash commands:${a === 0 ? '' : ' (Continued)'}`,
allSlashCommands[a]
)
.addField('List of global slash commands:', allSlashCommands)
}

if (guild) {
const guildOnly = await slashCommands.get(guild.id)

let guildOnlyCommands = ''
counter = 0
let guildOnlyCommands: string[] = []

if (guildOnly.size) {
guildOnly.forEach((cmd: ApplicationCommand) => {
guildOnlyCommands += `${cmd.name}: ${cmd.id}\n`
const newString = `${cmd.name}: ${cmd.id}\n`

if (!guildOnlyCommands[counter]) {
guildOnlyCommands[counter] = ''
}

if (guildOnlyCommands[counter].length + newString.length < 1024) {
guildOnlyCommands[counter] += newString
} else {
guildOnlyCommands[++counter] += newString
}
})
} else {
guildOnlyCommands = 'None'
guildOnlyCommands[0] = 'None'
}

embed.addField(
'List of slash commands for this guild:',
guildOnlyCommands
)
for (let a = 0; a < guildOnlyCommands.length; ++a) {
embed.addField(
`Guild slash commands:${a === 0 ? '' : ' (Continued)'}`,
guildOnlyCommands[a]
)
}
}

if (instance.color) {
Expand Down

0 comments on commit aa2480c

Please sign in to comment.