Merge branch 'dev' into 'main'

Added sorting to ranks based on position

See merge request illegitimate/illegitimate-bot!123
This commit is contained in:
2023-12-05 14:32:16 +00:00
7 changed files with 44 additions and 11 deletions

View File

@@ -11,7 +11,7 @@ module.exports = {
data: new SlashCommandBuilder()
.setName("ban")
.setDescription("Ban a user")
.setDescription("Bans a user")
.addUserOption(option =>
option
.setName("user")

View File

@@ -9,6 +9,16 @@ module.exports = {
type: "slash",
dev: false,
public: true,
subcommands: [
{
name: "member",
description: "Get info about a guild memeber",
},
{
name: "info",
description: "Get info about a guild.",
}
],
data: new SlashCommandBuilder()
.setName("guild")
@@ -31,7 +41,7 @@ module.exports = {
.addStringOption(option =>
option
.setName("query")
.setDescription("The IGN of a member.")
.setDescription("The query to search for. [Default: player]")
.setRequired(true)
).
addStringOption(option =>

View File

@@ -127,7 +127,8 @@ async function guildInfo(interaction) {
const guildOwner = guildMembers.find((m) => m.rank === "Guild Master").uuid
const guildOwnerName = await getIGN(guildOwner)
const guildRanks = guild.ranks.map((r) => "**➺ " + r.name + "** `[" + r.tag + "]`").join("\n")
const guildRanksUnsorted = guild.ranks.sort((a, b) => b.priority - a.priority)
const guildRanks = guildRanksUnsorted.map((r) => "**➺ " + r.name + "** `[" + r.tag + "]`").join("\n")
const guildMembersDailyXP = Object.values(guildMembers).map((m) => m.expHistory[Object.keys(m.expHistory)[0]])
const totalGuildMembersDailyXPUnformatted = guildMembersDailyXP.reduce((a, b) => a + b, 0)

View File

@@ -11,7 +11,7 @@ module.exports = {
data: new SlashCommandBuilder()
.setName("help")
.setDescription("Help command")
.setDescription("List's all commands usable by a member")
.setDMPermission(true),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
@@ -24,10 +24,26 @@ module.exports = {
const commandFiles = fs.readdirSync(__dirname).filter(file => file.endsWith(".js"))
for (const file of commandFiles) {
const command = require(`./${file}`)
if (command.public) {
if (command.public && !command.subcommands) {
commands.push(command)
} else if (command.public && command.subcommands) {
const commandName = command.name
const subcommands = command.subcommands.map((subcommand) => {
return {
name: commandName + " " + subcommand.name,
description: subcommand.description
}
})
console.log(subcommands)
for (const subcommand of subcommands) {
commands.push(subcommand)
}
}
}
const commandList = commands.map((command) => {
return {
name: "**/" + command.name + "**",

View File

@@ -10,7 +10,7 @@ module.exports = {
data: new SlashCommandBuilder()
.setName("ping")
.setDescription("Get the bot's ping."),
.setDescription("Get's the bot's ping."),
/**
* @param { import("discord.js").ChatInputCommandInteraction } interaction

View File

@@ -14,7 +14,7 @@ module.exports = {
data: new SlashCommandBuilder()
.setName("update")
.setDescription("Update your guild rank.")
.setDescription("Update your discord roles.")
.setDMPermission(false),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */

View File

@@ -8,10 +8,16 @@ module.exports = {
execute(interaction) {
if (interaction.isCommand()) {
console.log(interaction.user.username + "#" +
interaction.user.discriminator + " ran " +
interaction.commandName
)
try {
console.log(interaction.user.username + " ran " +
interaction.commandName + " " +
interaction.options.getSubcommand()
)
} catch {
console.log(interaction.user.username + " ran " +
interaction.commandName
)
}
} else if (interaction.isButton()) {
console.log(interaction.user.username + "#" +
interaction.user.discriminator + " clicked " +