xernerx 4.13.0 → 4.13.1

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,10 +1,13 @@
1
1
  /** @format */
2
- import { EmbedBuilder, InteractionEditReplyOptions, InteractionReplyOptions, MessagePayload } from 'discord.js';
2
+ import { EmbedBuilder, InteractionEditReplyOptions, InteractionReplyOptions, MessageCreateOptions, MessagePayload } from 'discord.js';
3
3
  import XernerxClient from '../client/XernerxClient.js';
4
4
  import { ContextCommandArguments, PaginatorOptions, SlashCommandArguments } from '../types/interfaces.js';
5
5
  import { XernerxInteraction } from '../types/types.js';
6
6
  import Util from './Util.js';
7
- import { XernerxMessageContextInteraction, XernerxSlashInteraction, XernerxUserContextInteraction } from '../types/extenders.js';
7
+ import { XernerxMessageContextInteraction, XernerxSlashInteraction, XernerxUser, XernerxUserContextInteraction } from '../types/extenders.js';
8
+ type MimicOptions = {
9
+ timeout: number;
10
+ };
8
11
  export default class InteractionUtil extends Util {
9
12
  private readonly interaction;
10
13
  parsed: {
@@ -14,6 +17,8 @@ export default class InteractionUtil extends Util {
14
17
  constructor(client: XernerxClient, interaction: XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>);
15
18
  send(content: any): Promise<import("discord.js").Message<false> | import("discord.js").Message<true> | undefined>;
16
19
  reply(content: string | MessagePayload | InteractionReplyOptions | InteractionEditReplyOptions): Promise<import("discord.js").InteractionResponse<boolean> | import("discord.js").Message<boolean>>;
20
+ mimic(user: XernerxUser | string, interaction: MessageCreateOptions, options: MimicOptions): Promise<void>;
17
21
  private commandName;
18
22
  paginator(embeds: Array<EmbedBuilder>, options?: PaginatorOptions): Promise<void | import("discord.js").Message<false> | import("discord.js").Message<true>>;
19
23
  }
24
+ export {};
@@ -1,5 +1,5 @@
1
1
  /** @format */
2
- import { ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder } from 'discord.js';
2
+ import { ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder, } from 'discord.js';
3
3
  import Util from './Util.js';
4
4
  import XernerxError from '../tools/XernerxError.js';
5
5
  export default class InteractionUtil extends Util {
@@ -21,6 +21,23 @@ export default class InteractionUtil extends Util {
21
21
  throw new XernerxError(`Can't send a message without content.`);
22
22
  return await (this.interaction.replied || this.interaction.deferred ? this.interaction.editReply(content) : this.interaction.reply(content));
23
23
  }
24
+ async mimic(user, interaction, options) {
25
+ user = (typeof user == 'string' ? (await this.client.users.fetch(user)) : user);
26
+ const webhooks = await this.interaction.channel.fetchWebhooks();
27
+ const webhook = webhooks.find((wh) => wh.token) ||
28
+ (await this.interaction.channel.createWebhook({
29
+ name: `${this.client.user?.username}'s mimic webhook.`,
30
+ avatar: user.displayAvatarURL() || this.client.user?.displayAvatarURL(),
31
+ }));
32
+ await webhook.send({
33
+ content: interaction.content,
34
+ username: user.username,
35
+ avatarURL: user.displayAvatarURL(),
36
+ });
37
+ setTimeout(() => {
38
+ webhook.delete().catch(() => true);
39
+ }, options.timeout);
40
+ }
24
41
  // @ts-ignore
25
42
  commandName() { }
26
43
  async paginator(embeds, options = {}) {
@@ -5,7 +5,6 @@ import { XernerxMessage, XernerxUser } from '../types/extenders.js';
5
5
  import Util from './Util.js';
6
6
  import { PaginatorOptions } from '../types/interfaces.js';
7
7
  type MimicOptions = {
8
- url: string;
9
8
  timeout: number;
10
9
  };
11
10
  export default class MessageUtil extends Util {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xernerx",
3
- "version": "4.13.0",
3
+ "version": "4.13.1",
4
4
  "description": "A bot framework for discord.js.",
5
5
  "main": "dist/main.js",
6
6
  "type": "module",