@fallencodes/seyfert-utils 1.3.6 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { OKFunction, GuildRole, StopFunction, AllGuildChannels, CommandContext } from 'seyfert';
1
+ import { OKFunction, GuildRole, StopFunction, AllGuildChannels, CommandContext, User } from 'seyfert';
2
2
  interface StringOption {
3
3
  value: string;
4
4
  context: CommandContext;
@@ -9,5 +9,6 @@ export declare function dateOptionValue({ value }: StringOption, ok: OKFunction<
9
9
  export declare function relativeTimeOptionValue({ value }: StringOption, ok: OKFunction<number>, fail: StopFunction): void;
10
10
  export declare function rolesOptionValue({ value: values, context }: StringOption, ok: OKFunction<[GuildRole, ...GuildRole[]]>, fail: StopFunction): Promise<void>;
11
11
  export declare function channelsOptionValue({ value: values, context }: StringOption, ok: OKFunction<[AllGuildChannels, ...AllGuildChannels[]]>, fail: StopFunction): Promise<void>;
12
+ export declare function usersOptionValue({ value: values, context }: StringOption, ok: OKFunction<[User, ...User[]]>, fail: StopFunction): Promise<void>;
12
13
  export {};
13
14
  //# sourceMappingURL=options.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAOhG,UAAU,YAAY;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,cAAc,CAAC;CAC3B;AAGD,eAAO,MAAM,oBAAoB,GAAI,WAAW,YAAY,EAAE,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,YAAY,SAGvG,CAAC;AAGF,eAAO,MAAM,mBAAmB,GAAI,WAAW,YAAY,EAAE,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,YAAY,SAStG,CAAC;AAGF,wBAAgB,eA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IAAI,EAAE,YAAY,QAIhG;AAGD,wBAAgB,uBAAuB,CAAC,EAAE,KAAK,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,YAAY,QAI1G;AAGD,wBAAsB,gBAAgB,CAClC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,YAAY,EACxC,EAAE,EAAE,UAAU,CAAC,CAAC,SAAS,EAAE,GAAG,SAAS,EAAE,CAAC,CAAC,EAC3C,IAAI,EAAE,YAAY,iBA4BrB;AAGD,wBAAsB,mBAAmB,CACrC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,YAAY,EACxC,EAAE,EAAE,UAAU,CAAC,CAAC,gBAAgB,EAAE,GAAG,gBAAgB,EAAE,CAAC,CAAC,EACzD,IAAI,EAAE,YAAY,iBA8BrB;AAED,wBAAsB,gBAAgB,CAClC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,YAAY,EACxC,EAAE,EAAE,UAAU,CAAC,CAAC,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC,EACjC,IAAI,EAAE,YAAY,iBAkBrB"}
package/build/options.js CHANGED
@@ -2,7 +2,7 @@ import { isValidSnowflake } from './utilities.js';
2
2
  import dayjs from 'dayjs';
3
3
  import ms from 'ms';
4
4
  import fuzzy from 'fuzzysort';
5
- import { channelMentionRegex, hexRegex, roleMentionRegex } from './variables.js';
5
+ import { channelMentionRegex, hexRegex, roleMentionRegex, userMentionRegex } from './variables.js';
6
6
  /* Returns a valid string snowflake value. */
7
7
  export const snowflakeOptionValue = ({ value }, ok, fail) => {
8
8
  if (isValidSnowflake(value))
@@ -106,3 +106,24 @@ export async function channelsOptionValue({ value: values, context }, ok, fail)
106
106
  ok(resolvedChannels);
107
107
  }
108
108
  ;
109
+ export async function usersOptionValue({ value: values, context }, ok, fail) {
110
+ const resolvedUsers = [];
111
+ for await (const value of values.split(',').map((value) => value.trim())) {
112
+ let user;
113
+ const mentionMatch = userMentionRegex.exec(value)?.[1];
114
+ if (mentionMatch)
115
+ user = await context.client.users.fetch(mentionMatch).catch(() => undefined);
116
+ if (!user && isValidSnowflake(value))
117
+ user = await context.client.users.fetch(value).catch(() => undefined);
118
+ if (user)
119
+ resolvedUsers.push(user);
120
+ else
121
+ return fail(`Hold up! | The specified user "${user}" wasn't found.`);
122
+ }
123
+ ;
124
+ if (resolvedUsers.length < 1)
125
+ return fail(`Hold up! | You didn't specify any valid users.`);
126
+ // @ts-expect-error
127
+ ok(resolvedUsers);
128
+ }
129
+ ;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fallencodes/seyfert-utils",
3
3
  "type": "module",
4
- "version": "1.3.6",
4
+ "version": "1.4.0",
5
5
  "license": "MIT",
6
6
  "description": "A collection of various utility/helper code I use in my Seyfert projects.",
7
7
  "main": "build/index.js",