diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-08-19 12:03:21 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-08-19 12:03:21 -0400 |
commit | b29a217f76483e000bd9d75d30250d11a0a88c4d (patch) | |
tree | 041b13dc115cf94aff81cda17cf088f2290c2a14 /src/commands/info | |
parent | 5984cc283ca50099d0e266b994324446316c0013 (diff) | |
download | tanzanite-b29a217f76483e000bd9d75d30250d11a0a88c4d.tar.gz tanzanite-b29a217f76483e000bd9d75d30250d11a0a88c4d.tar.bz2 tanzanite-b29a217f76483e000bd9d75d30250d11a0a88c4d.zip |
added steal command, revamped error handling and other stuff
Diffstat (limited to 'src/commands/info')
-rw-r--r-- | src/commands/info/links.ts (renamed from src/commands/info/invite.ts) | 25 | ||||
-rw-r--r-- | src/commands/info/pronouns.ts | 14 | ||||
-rw-r--r-- | src/commands/info/snowflakeInfo.ts | 11 | ||||
-rw-r--r-- | src/commands/info/userInfo.ts | 19 |
4 files changed, 53 insertions, 16 deletions
diff --git a/src/commands/info/invite.ts b/src/commands/info/links.ts index 615e767..29152d9 100644 --- a/src/commands/info/invite.ts +++ b/src/commands/info/links.ts @@ -1,15 +1,16 @@ import { BushCommand, BushMessage, BushSlashMessage } from '@lib'; import { MessageActionRow, MessageButton } from 'discord.js'; +import packageDotJSON from '../../../package.json'; -export default class InviteCommand extends BushCommand { +export default class LinksCommand extends BushCommand { public constructor() { - super('invite', { - aliases: ['invite'], + super('links', { + aliases: ['links', 'invite', 'support'], category: 'info', description: { - content: 'Sends the bot invite link.', - usage: 'invite', - examples: ['invite'] + content: 'Sends bot links', + usage: 'links', + examples: ['links'] }, ratelimit: 4, cooldown: 4000, @@ -27,8 +28,18 @@ export default class InviteCommand extends BushCommand { url: `https://discord.com/api/oauth2/authorize?client_id=${ client.user!.id }&permissions=2147483647&scope=bot%20applications.commands` + }), + new MessageButton({ + style: 'LINK', + label: 'Support Server', + url: client.config.supportGuild.invite + }), + new MessageButton({ + style: 'LINK', + label: 'GitHub', + url: packageDotJSON.repository }) ); - return await message.util.reply({ content: 'You can invite me here:', components: [ButtonRow] }); + return await message.util.reply({ content: '\u200B', components: [ButtonRow] }); } } diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts index c7eac7f..96040c0 100644 --- a/src/commands/info/pronouns.ts +++ b/src/commands/info/pronouns.ts @@ -40,7 +40,7 @@ export default class PronounsCommand extends BushCommand { args: [ { id: 'user', - type: 'user', + customType: util.arg.union('user', 'bigint'), prompt: { start: 'Who would you like to view the pronouns of?', retry: '{error} Choose a valid user to view the pronouns of.', @@ -60,8 +60,16 @@ export default class PronounsCommand extends BushCommand { slash: true }); } - override async exec(message: BushMessage | BushSlashMessage, args: { user?: User }): Promise<unknown> { - const user = args.user ?? message.author; + override async exec(message: BushMessage | BushSlashMessage, args: { user?: User | string }): Promise<unknown> { + const user = + args?.user === undefined || args?.user === null + ? message.author + : typeof args.user === 'object' + ? args.user + : await client.users.fetch(`${args.user}`).catch(() => undefined); + + if (user === undefined) return message.util.reply(`${util.emojis.error} Invalid user.`); + const author = user.id === message.author.id; try { const apiRes: { pronouns: pronounsType } = await got diff --git a/src/commands/info/snowflakeInfo.ts b/src/commands/info/snowflakeInfo.ts index c4d71da..02c8d39 100644 --- a/src/commands/info/snowflakeInfo.ts +++ b/src/commands/info/snowflakeInfo.ts @@ -88,7 +88,7 @@ export default class SnowflakeInfoCommand extends BushCommand { } // Guild - else if (client.guilds.cache.has(snowflake)) { + if (client.guilds.cache.has(snowflake)) { const guild: Guild = client.guilds.cache.get(snowflake)!; const guildInfo = [ `**Name:** ${guild.name}`, @@ -101,8 +101,9 @@ export default class SnowflakeInfoCommand extends BushCommand { } // User - else if (client.users.cache.has(snowflake)) { - const user: User = client.users.cache.get(snowflake)!; + const fetchedUser = await client.users.fetch(`${snowflake}`).catch(() => undefined); + if (client.users.cache.has(snowflake) || fetchedUser) { + const user: User = (client.users.cache.get(snowflake) ?? fetchedUser)!; const userInfo = [`**Name:** <@${user.id}> (${user.tag})`]; if (user.avatar) snowflakeEmbed.setThumbnail(user.avatarURL({ size: 2048, dynamic: true })!); snowflakeEmbed.addField('» User Info', userInfo.join('\n')); @@ -110,7 +111,7 @@ export default class SnowflakeInfoCommand extends BushCommand { } // Emoji - else if (client.emojis.cache.has(snowflake)) { + if (client.emojis.cache.has(snowflake)) { const emoji: Emoji = client.emojis.cache.get(snowflake)!; const emojiInfo = [`**Name:** ${emoji.name}`, `**Animated:** ${emoji.animated}`]; if (emoji.url) snowflakeEmbed.setThumbnail(emoji.url); @@ -119,7 +120,7 @@ export default class SnowflakeInfoCommand extends BushCommand { } // Role - else if (message.guild && message.guild.roles.cache.has(snowflake)) { + if (message.guild && message.guild.roles.cache.has(snowflake)) { const role: Role = message.guild.roles.cache.get(snowflake)!; const roleInfo = [ `**Name:** <@&${role.id}> (${role.name})`, diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts index 9ec5552..7b8d7d8 100644 --- a/src/commands/info/userInfo.ts +++ b/src/commands/info/userInfo.ts @@ -1,7 +1,6 @@ import { BushCommand, BushMessage, BushSlashMessage, BushUser } from '@lib'; import { MessageEmbed } from 'discord.js'; -// TODO: Re-Implement Status Emojis // TODO: Add bot information export default class UserInfoCommand extends BushCommand { public constructor() { @@ -141,6 +140,24 @@ export default class UserInfoCommand extends BushCommand { presenceInfo.push(`**Activit${activitiesNames.length - 1 ? 'ies' : 'y'}:** ${util.oxford(activitiesNames, 'and', '')}`); if (customStatus && customStatus.length) presenceInfo.push(`**Custom Status:** ${customStatus}`); userEmbed.addField('» Presence', presenceInfo.join('\n')); + + enum statusEmojis { + online = '787550449435803658', + idle = '787550520956551218', + dnd = '787550487633330176', + offline = '787550565382750239', + invisible = '787550565382750239' + } + userEmbed.setFooter(user.tag, client.emojis.cache.get(statusEmojis[member?.presence.status])?.url ?? undefined); + } + + // roles + if (member?.roles.cache.size && member?.roles.cache.size - 1) { + const roles = member?.roles.cache + .filter((role) => role.name !== '@everyone') + .sort((role1, role2) => role2.position - role1.position) + .map((role) => `${role}`); + userEmbed.addField(`» Role${roles.length - 1 ? 's' : ''} [${roles.length}]`, roles.join(', ')); } // Important Perms |