Guild
Guild List Command
The guildlist command lists all guilds the bot is currently in, displayed in paginated embeds. This command is restricted to developers or staff only.
Command Details
- Name: guildlist
- Aliases: glt
- Category: Guild
- Description: List all guilds the bot is in
- Usage:
guildlist
- Examples:
guildlist
- Cooldown: 3 seconds
- Arguments: None
- Slash Command: Disabled
- Permissions:
- Bot: SendMessages, ViewChannel, EmbedLinks
- User: Developer or Staff only
- Player Requirements: None
Functionality
- Retrieves all guilds the bot is currently in from the client's cache.
- Displays each guild with its Name and ID.
- Groups guilds into chunks of 10 per page for paginated display.
- Uses reaction-based pagination to navigate between pages.
- Each page is an embed with a footer indicating the current page and total pages.
Code Overview
The command:
- Extends the
Command
class from../../structures/index.js
. - Uses the
run
method to handle command execution. - Maps the bot's guilds to a formatted string containing guild name and ID.
- Utilizes
client.utils.chunk
to split the guild list into groups of 10. - Creates an embed for each chunk with
client.embed()
, setting the description and footer. - Employs
client.utils.reactionPaginate
for paginated navigation.
const { Command } = require("../../structures/index.js");
module.exports = class GuildList extends Command {
constructor(client) {
super(client, {
name: "guildlist",
description: {
content: "List all guilds the bot is in",
examples: ["guildlist"],
usage: "guildlist",
},
category: "guild",
aliases: ["glt"],
cooldown: 3,
args: false,
permissions: {
dev: true,
staff: true,
client: ["SendMessages", "ViewChannel", "EmbedLinks"],
user: [],
},
slashCommand: false,
options: [],
});
}
async run(client, ctx, args, color, emoji, language) {
const guilds = client.guilds.cache.map(
(g) => `Name : **${g.name}**\nID : **${g.id}**`,
);
let chunks = client.utils.chunk(guilds, 10);
if (chunks.length === 0) chunks = 1;
const pages = [];
for (let i = 0; i < chunks.length; i++) {
const embed = client
.embed()
.setColor(color.main)
.setDescription(chunks[i].join("\n\n"))
.setFooter({ text: `Page ${i + 1} of ${chunks.length}` });
pages.push(embed);
}
return await client.utils.reactionPaginate(ctx, pages);
}
};
Guild Leave Command
The guildleave command allows the bot to leave a specified guild. This command is restricted to developers or staff only.
Apply Job
The applyjob command allows users to apply for a job from available positions such as Police, IT, Doctor, Teacher, Engineer, or Student. This command supports both message and slash command usage.