Guild
Guild Leave Command
The guildleave command allows the bot to leave a specified guild. This command is restricted to developers or staff only.
Command Details
- Name: guildleave
- Aliases: gl
- Category: Guild
- Description: Leave a guild
- Usage:
guildleave <guildID>
- Examples:
guildleave 123456789012345678
- Cooldown: 3 seconds
- Arguments: Yes (Guild ID)
- Slash Command: Disabled
- Permissions:
- Bot: SendMessages, ViewChannel, EmbedLinks
- User: Developer or Staff only
- Player Requirements: None
Functionality
- Checks if the provided guild ID corresponds to a guild in the bot's cache.
- If the guild is found, the bot attempts to leave it.
- Sends a success message upon leaving the guild or an error message if the guild is not found.
- Logs any errors during the guild leave process to the console.
Code Overview
The command:
- Extends the
Command
class from../../structures/index.js
. - Uses the
run
method to handle command execution. - Retrieves the guild from the client's cache using the provided guild ID.
- Calls
guild.leave()
to exit the guild and handles errors with a catch block. - Utilizes
client.utils.sendSuccessMessage
to confirm the action.
const { Command } = require("../../structures/index.js");
module.exports = class GuildLeave extends Command {
constructor(client) {
super(client, {
name: "guildleave",
description: {
content: "Leave a guild",
examples: ["guildleave"],
usage: "guildleave",
},
category: "guild",
aliases: ["gl"],
cooldown: 3,
args: false,
permissions: {
dev: true,
staff: true,
client: ["SendMessages", "ViewChannel", "EmbedLinks"],
user: [],
},
slashCommand: false,
options: [],
});
}
run(client, ctx, args, color, emoji, language) {
const guild = client.guilds.cache.get(args[0]);
if (!guild) return ctx.sendMessage("Guild not found");
guild.leave().catch((err) => console.error(err));
return client.utils.sendSuccessMessage(
client,
ctx,
`Left guild ${guild.name}`,
color,
);
}
}
Guild Info
The `guildinfo` command fetches detailed information about a guild and generates an invite link. This command is for developers only.
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.