created TargetID

This commit is contained in:
mmacierzanka committed 2021-09-07 20:49:35 +02:00
1 parent 1e2966dfa9
commit 722f355d9b
3 files changed
+16 -8

No files matched your search

+2 -2
View File
@@ -3,7 +3,7 @@ import { CommandInteractionData } from "../types/commands.js";
import { MessageCommand } from "../structures/MessageCommand.js";
import { CommandManager } from "./CommandManager.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 {
protected readonly _list: MessageCommand[] = [];
@@ -31,7 +31,7 @@ export class MessageCommandManager extends CommandManager {
optional: false,
type: "target",
});
const inputParameter = new TargetParameter(parameter, i.targetId);
const inputParameter = new TargetParameter(parameter, new TargetID(i.targetId));
return {
command: command,
parameters: [inputParameter],
+12 -4
View File
@@ -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";
/**
@@ -164,15 +164,23 @@ export class NullParameter extends InputParameter {
}
export class TargetParameter extends InputParameter {
constructor(parameter: Parameter, targetId: string) {
constructor(parameter: Parameter, targetId: TargetID) {
super(parameter, targetId);
}
}
export class TargetID {
public readonly id: string;
constructor(id: string) {
this.id = id;
}
toMessage(c: TextChannel) {
return c.messages.cache.get(this.value?.toString() || "");
return c.messages.cache.get(this.id.toString() || "");
}
async toUser(g: Guild) {
return await g.members.fetch({ query: this.value?.toString() });
return await g.members.fetch({ query: this.id.toString() });
}
}
+2 -2
View File
@@ -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 ParameterResolvable = string | boolean | number | ObjectID | null;
export type ParameterResolvable = string | boolean | number | ObjectID | TargetID | null;
/**
* @interface