aboutsummaryrefslogtreecommitdiff
path: root/src/commands/info/icon.ts
blob: b3434ecd3cd32dc09d1d3dd68800e62bbec66616 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { BushCommand, clientSendAndPermCheck, colors, type CommandMessage, type SlashMessage } from '#lib';
import assert from 'assert/strict';
import { EmbedBuilder, escapeMarkdown, PermissionFlagsBits } from 'discord.js';

export default class IconCommand extends BushCommand {
	public constructor() {
		super('icon', {
			aliases: ['icon', 'guildavatar', 'severicon', 'guildicon'],
			category: 'info',
			description: "A command to get the server's icon",
			usage: ['icon'],
			examples: ['icon'],
			clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true),
			userPermissions: [],
			channel: 'guild',
			slash: true
		});
	}

	public override async exec(message: CommandMessage | SlashMessage) {
		assert(message.inGuild());

		const embed = new EmbedBuilder()
			.setTimestamp()
			.setColor(colors.default)
			.setImage(
				message.guild.iconURL({
					size: 2048,
					extension: 'png'
				})!
			)
			.setTitle(escapeMarkdown(message.guild.name));
		await message.util.reply({ embeds: [embed] });
	}
}