Archived
created TargetID
This commit is contained in:
1 parent
1e2966dfa9
commit
722f355d9b
3 files changed
+16
-8
No files matched your search
@@ -3,7 +3,7 @@ import { CommandInteractionData } from "../types/commands.js";
|
|||||||
import { MessageCommand } from "../structures/MessageCommand.js";
|
import { MessageCommand } from "../structures/MessageCommand.js";
|
||||||
import { CommandManager } from "./CommandManager.js";
|
import { CommandManager } from "./CommandManager.js";
|
||||||
import { CommandNotFound } from "../errors.js";
|
import { CommandNotFound } from "../errors.js";
|
||||||
import { Parameter, TargetParameter } from "../structures/Parameter.js";
|
import { Parameter, TargetID, TargetParameter } from "../structures/Parameter.js";
|
||||||
|
|
||||||
export class MessageCommandManager extends CommandManager {
|
export class MessageCommandManager extends CommandManager {
|
||||||
protected readonly _list: MessageCommand[] = [];
|
protected readonly _list: MessageCommand[] = [];
|
||||||
@@ -31,7 +31,7 @@ export class MessageCommandManager extends CommandManager {
|
|||||||
optional: false,
|
optional: false,
|
||||||
type: "target",
|
type: "target",
|
||||||
});
|
});
|
||||||
const inputParameter = new TargetParameter(parameter, i.targetId);
|
const inputParameter = new TargetParameter(parameter, new TargetID(i.targetId));
|
||||||
return {
|
return {
|
||||||
command: command,
|
command: command,
|
||||||
parameters: [inputParameter],
|
parameters: [inputParameter],
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { CategoryChannel, Guild, GuildMember, NewsChannel, Role, StageChannel, StoreChannel, TextChannel, VoiceChannel } from "discord.js";
|
import { CategoryChannel, Guild, GuildMember, Message, NewsChannel, Role, StageChannel, StoreChannel, TextChannel, VoiceChannel } from "discord.js";
|
||||||
import { ParameterType, ParameterResolvable, ParameterSchema } from "../types/Parameter.js";
|
import { ParameterType, ParameterResolvable, ParameterSchema } from "../types/Parameter.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -164,15 +164,23 @@ export class NullParameter extends InputParameter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class TargetParameter extends InputParameter {
|
export class TargetParameter extends InputParameter {
|
||||||
constructor(parameter: Parameter, targetId: string) {
|
constructor(parameter: Parameter, targetId: TargetID) {
|
||||||
super(parameter, targetId);
|
super(parameter, targetId);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class TargetID {
|
||||||
|
public readonly id: string;
|
||||||
|
|
||||||
|
constructor(id: string) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
toMessage(c: TextChannel) {
|
toMessage(c: TextChannel) {
|
||||||
return c.messages.cache.get(this.value?.toString() || "");
|
return c.messages.cache.get(this.id.toString() || "");
|
||||||
}
|
}
|
||||||
|
|
||||||
async toUser(g: Guild) {
|
async toUser(g: Guild) {
|
||||||
return await g.members.fetch({ query: this.value?.toString() });
|
return await g.members.fetch({ query: this.id.toString() });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import { ObjectID } from "../structures/Parameter.js";
|
import { ObjectID, TargetID } from "../structures/Parameter.js";
|
||||||
|
|
||||||
export type ParameterType = "string" | "boolean" | "number" | "user" | "role" | "channel" | "mentionable" | "target";
|
export type ParameterType = "string" | "boolean" | "number" | "user" | "role" | "channel" | "mentionable" | "target";
|
||||||
|
|
||||||
export type ParameterResolvable = string | boolean | number | ObjectID | null;
|
export type ParameterResolvable = string | boolean | number | ObjectID | TargetID | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @interface
|
* @interface
|
||||||
|
|||||||
Reference in new issue
Block a user