@elara-services/tickets 4.0.8 → 4.1.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.
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  declare module "@elara-services/tickets" {
2
-
2
+
3
3
  import type { Client, MessageOptions, GuildMember, Guild, User, TextBasedChannel, Message, Interaction } from "discord.js";
4
4
 
5
5
  export type Langs = "en-US";
@@ -123,6 +123,11 @@ declare module "@elara-services/tickets" {
123
123
 
124
124
  private _debug(...args: unknown[]): unknown;
125
125
 
126
+ public get manage(): {
127
+ add(channelId: string, userId: string, permType: "member" | "mod"): Promise<{ status: boolean, message: string }>;
128
+ remove(channelId: string, userId: string): Promise<{ status: boolean, message: string }>;
129
+ };
130
+
126
131
  public get webhookOptions(): {
127
132
  id: string | undefined;
128
133
  token: string | undefined;
@@ -141,7 +146,7 @@ declare module "@elara-services/tickets" {
141
146
  public button(options: { style: 1 | 2 | 3 | 4 | 5 | number, id?: string, label?: string, emoji?: { name?: string, id?: string } }): { type: number, custom_id: string, style: number, label?: string, emoji?: { name?: string, id?: string } }
142
147
  public closeTicket(options: {
143
148
  member: GuildMember,
144
- guild: Guild,
149
+ guild: Guild,
145
150
  user: User,
146
151
  messages: Message[],
147
152
  channel: TextBasedChannel
package/lib/v13.js CHANGED
@@ -495,18 +495,20 @@ module.exports = class Tickets extends base {
495
495
  }
496
496
  }
497
497
  if (this.options.ticket?.supportCommentThread === true) {
498
- await channel.threads
498
+ const thread = await channel.threads
499
499
  .create({
500
500
  name: this.str("SUPPORT_TALK"),
501
501
  invitable: false,
502
502
  type: 12,
503
- startMessage: !this.getSupportIds.empty
504
- ? {
505
- content: `${this.getSupportIds.roles.length ? this.getSupportIds.roles.map((c) => `<@&${c}>`).join(" ") : ""}${this.getSupportIds.users.length ? `${this.getSupportIds.roles.length ? ` | ` : ""}${this.getSupportIds.users.map((c) => `<@${c}>`).join(" ")}` : ""}`,
506
- }
507
- : undefined,
508
503
  })
509
504
  .catch((e) => this._debug(e));
505
+ if (thread && !this.getSupportIds.empty) {
506
+ await thread
507
+ .send({
508
+ content: `${this.getSupportIds.roles.length ? this.getSupportIds.roles.map((c) => `<@&${c}>`).join(" ") : ""}${this.getSupportIds.users.length ? `${this.getSupportIds.roles.length ? ` | ` : ""}${this.getSupportIds.users.map((c) => `<@${c}>`).join(" ")}` : ""}`,
509
+ })
510
+ .catch((e) => this._debug(e));
511
+ }
510
512
  }
511
513
  if (this.webhookOptions.id && this.webhookOptions.token) {
512
514
  webhook(this.webhookOptions)
package/lib/v14.js CHANGED
@@ -491,18 +491,20 @@ module.exports = class Tickets extends base {
491
491
  }
492
492
  }
493
493
  if (this.options.ticket?.supportCommentThread === true) {
494
- await channel.threads
494
+ const thread = await channel.threads
495
495
  .create({
496
496
  name: this.str("SUPPORT_TALK"),
497
497
  invitable: false,
498
498
  type: 12,
499
- startMessage: !this.getSupportIds.empty
500
- ? {
501
- content: `${this.getSupportIds.roles.length ? this.getSupportIds.roles.map((c) => `<@&${c}>`).join(" ") : ""}${this.getSupportIds.users.length ? `${this.getSupportIds.roles.length ? ` | ` : ""}${this.getSupportIds.users.map((c) => `<@${c}>`).join(" ")}` : ""}`,
502
- }
503
- : undefined,
504
499
  })
505
500
  .catch((e) => this._debug(e));
501
+ if (thread && !this.getSupportIds.empty) {
502
+ await thread
503
+ .send({
504
+ content: `${this.getSupportIds.roles.length ? this.getSupportIds.roles.map((c) => `<@&${c}>`).join(" ") : ""}${this.getSupportIds.users.length ? `${this.getSupportIds.roles.length ? ` | ` : ""}${this.getSupportIds.users.map((c) => `<@${c}>`).join(" ")}` : ""}`,
505
+ })
506
+ .catch((e) => this._debug(e));
507
+ }
506
508
  }
507
509
  if (this.webhookOptions.id && this.webhookOptions.token) {
508
510
  webhook(this.webhookOptions)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elara-services/tickets",
3
- "version": "4.0.8",
3
+ "version": "4.1.0",
4
4
  "description": "Helper for tickets",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",