aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/arguments/globalUser.ts8
-rw-r--r--src/commands/info/avatar.ts26
-rw-r--r--src/commands/info/userInfo.ts8
-rw-r--r--src/commands/utilities/activity.ts36
-rw-r--r--src/lib/extensions/discord-akairo/BushClient.ts4
-rw-r--r--src/lib/extensions/discord-akairo/BushCommand.ts3
6 files changed, 58 insertions, 27 deletions
diff --git a/src/arguments/globalUser.ts b/src/arguments/globalUser.ts
new file mode 100644
index 0000000..3a71732
--- /dev/null
+++ b/src/arguments/globalUser.ts
@@ -0,0 +1,8 @@
+import { BushArgumentTypeCaster, BushUser } from '@lib';
+
+// resolve non-cached users
+export const globalUserTypeCaster: BushArgumentTypeCaster = async (_, phrase): Promise<BushUser | null> => {
+ return client.users.cache.has(phrase)
+ ? client.users.cache.get(`${phrase}`) ?? null
+ : await client.users.fetch(`${phrase}`).catch(() => null);
+};
diff --git a/src/commands/info/avatar.ts b/src/commands/info/avatar.ts
index 7654d2f..1e6496a 100644
--- a/src/commands/info/avatar.ts
+++ b/src/commands/info/avatar.ts
@@ -1,4 +1,4 @@
-import { MessageEmbed, User } from 'discord.js';
+import { GuildMember, MessageEmbed, User } from 'discord.js';
import { BushCommand, BushMessage, BushSlashMessage } from '../../lib';
export default class AvatarCommand extends BushCommand {
@@ -14,7 +14,7 @@ export default class AvatarCommand extends BushCommand {
args: [
{
id: 'user',
- type: 'user',
+ customType: util.arg.union('member', 'globalUser'),
prompt: {
start: 'Who would you like to see the avatar of?',
retry: '{error} Choose a valid user.',
@@ -35,16 +35,20 @@ export default class AvatarCommand extends BushCommand {
});
}
- override async exec(message: BushMessage | BushSlashMessage, args: { user: User }): Promise<void> {
- const user = args.user ?? message.author;
+ override async exec(message: BushMessage | BushSlashMessage, args: { user: GuildMember | User }): Promise<void> {
+ const params: { size: 2048; format: 'png'; dynamic: true } = { size: 2048, format: 'png', dynamic: true };
+ const defaultAvatar = `https://cdn.discordapp.com/embed/avatars/${Math.ceil(Math.random() * 6) - 1}.png`;
+
+ const member = (args.user ?? message.member) instanceof GuildMember ? args.user ?? message.member : undefined;
+ const user = args.user instanceof GuildMember ? args.user.user : args.user ?? message.author;
+
+ const guildAvatar = member?.avatarURL(params);
+
+ const embed = new MessageEmbed().setTimestamp().setColor(util.colors.default).setTitle(`${user.tag}'s Avatar`);
+ guildAvatar
+ ? embed.setImage(guildAvatar).setThumbnail(user.avatarURL(params) ?? defaultAvatar)
+ : embed.setImage(user.avatarURL(params) ?? defaultAvatar);
- const embed = new MessageEmbed()
- .setTimestamp()
- .setColor(util.colors.default)
- .setTitle(`${user.tag}'s Avatar`)
- .setImage(
- user.avatarURL({ size: 2048, format: 'png', dynamic: true }) ?? 'https://cdn.discordapp.com/embed/avatars/0.png'
- );
await message.util.reply({ embeds: [embed] });
}
}
diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts
index b01c268..b55bbcf 100644
--- a/src/commands/info/userInfo.ts
+++ b/src/commands/info/userInfo.ts
@@ -4,12 +4,12 @@ import { MessageEmbed, Snowflake } from 'discord.js';
// TODO: Add bot information
export default class UserInfoCommand extends BushCommand {
public constructor() {
- super('userinfo', {
- aliases: ['userinfo', 'user', 'u'],
+ super('userInfo', {
+ aliases: ['user-info', 'user', 'u'],
category: 'info',
description: {
- usage: 'userinfo [user]',
- examples: ['userinfo 322862723090219008'],
+ usage: 'user-info [user]',
+ examples: ['user-info 322862723090219008'],
content: 'Gives information about a specified user.'
},
args: [
diff --git a/src/commands/utilities/activity.ts b/src/commands/utilities/activity.ts
index 30f11cb..de7e79f 100644
--- a/src/commands/utilities/activity.ts
+++ b/src/commands/utilities/activity.ts
@@ -7,7 +7,10 @@ const activityMap = {
'Fishington.io': '814288819477020702',
'YouTube Together': '755600276941176913',
'Chess in the Park': '832012774040141894',
- 'Watch Together': '880218394199220334'
+ 'Watch Together': '880218394199220334',
+ 'Doodle Crew': '878067389634314250',
+ 'Wood Snacks': '879863976006127627',
+ 'Letter Tile': '879863686565621790'
};
function map(phase: string) {
@@ -18,6 +21,9 @@ function map(phase: string) {
else if (['poker'].includes(phase)) return activityMap['Poker Night'];
else if (['fish', 'fishing', 'fishington'].includes(phase)) return activityMap['Fishington.io'];
else if (['betrayal'].includes(phase)) return activityMap['Betrayal.io'];
+ else if (['doodle-crew', 'doodle'].includes(phase)) return activityMap['Doodle Crew'];
+ else if (['wood-snacks', 'wood'].includes(phase)) return activityMap['Wood Snacks'];
+ else if (['letter-tile', 'letter'].includes(phase)) return activityMap['Letter Tile'];
else return null;
}
@@ -31,7 +37,24 @@ const activityTypeCaster = (_message: Message | BushMessage | BushSlashMessage,
export default class YouTubeCommand extends BushCommand {
constructor() {
super('activity', {
- aliases: ['activity', 'yt', 'youtube', 'chess', 'park', 'poker', 'fish', 'fishing', 'fishington', 'betrayal'],
+ aliases: [
+ 'activity',
+ 'yt',
+ 'youtube',
+ 'chess',
+ 'park',
+ 'poker',
+ 'fish',
+ 'fishing',
+ 'fishington',
+ 'betrayal',
+ 'doodle-crew',
+ 'doodle',
+ 'wood-snacks',
+ 'wood',
+ 'letter-tile',
+ 'letter'
+ ],
category: 'utilities',
description: {
content: 'Allows you to play discord activities in voice channels.',
@@ -74,14 +97,7 @@ export default class YouTubeCommand extends BushCommand {
description: 'What activity would you like to play?',
type: 'STRING',
required: true,
- choices: [
- { name: 'Poker Night', value: '755827207812677713' },
- { name: 'Betrayal.io', value: '773336526917861400' },
- { name: 'Fishington.io', value: '814288819477020702' },
- { name: 'YouTube Together', value: '755600276941176913' },
- { name: 'Chess in the Park', value: '832012774040141894' },
- { name: 'Watch Together', value: '880218394199220334' }
- ]
+ choices: Object.keys(activityMap).map((key) => ({ name: key, value: activityMap[key as keyof typeof activityMap] }))
}
],
clientPermissions: ['SEND_MESSAGES'],
diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts
index 065d141..0abc364 100644
--- a/src/lib/extensions/discord-akairo/BushClient.ts
+++ b/src/lib/extensions/discord-akairo/BushClient.ts
@@ -27,6 +27,7 @@ import { contentWithDurationTypeCaster } from '../../../arguments/contentWithDur
import { discordEmojiTypeCaster } from '../../../arguments/discordEmoji';
import { durationTypeCaster } from '../../../arguments/duration';
import { durationSecondsTypeCaster } from '../../../arguments/durationSeconds';
+import { globalUserTypeCaster } from '../../../arguments/globalUser';
import { permissionTypeCaster } from '../../../arguments/permission';
import { roleWithDurationTypeCaster } from '../../../arguments/roleWithDuation';
import { snowflakeTypeCaster } from '../../../arguments/snowflake';
@@ -329,7 +330,8 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re
discordEmoji: discordEmojiTypeCaster,
roleWithDuration: roleWithDurationTypeCaster,
abbreviatedNumber: abbreviatedNumberTypeCaster,
- durationSeconds: durationSecondsTypeCaster
+ durationSeconds: durationSecondsTypeCaster,
+ globalUser: globalUserTypeCaster
});
// loads all the handlers
const loaders = {
diff --git a/src/lib/extensions/discord-akairo/BushCommand.ts b/src/lib/extensions/discord-akairo/BushCommand.ts
index 548f921..0be128b 100644
--- a/src/lib/extensions/discord-akairo/BushCommand.ts
+++ b/src/lib/extensions/discord-akairo/BushCommand.ts
@@ -64,7 +64,8 @@ export type BaseBushArgumentType =
| 'snowflake'
| 'discordEmoji'
| 'roleWithDuration'
- | 'abbreviatedNumber';
+ | 'abbreviatedNumber'
+ | 'globalUser';
export type BushArgumentType = BaseBushArgumentType | RegExp;