mrmBot-Matrix/classes/command.js

70 lines
1.9 KiB
JavaScript
Raw Normal View History

class Command {
2022-03-22 20:43:26 +00:00
constructor(client, cluster, worker, ipc, options) {
this.client = client;
this.cluster = cluster;
2021-07-05 04:15:27 +00:00
this.worker = worker;
this.ipc = ipc;
this.origOptions = options;
2022-03-22 20:43:26 +00:00
this.type = options.type;
this.args = options.args;
if (options.type === "classic") {
this.message = options.message;
this.channel = options.message.channel;
this.author = options.message.author;
this.member = options.message.member;
2022-03-22 20:43:26 +00:00
this.content = options.content;
this.options = options.specialArgs;
2022-03-22 20:43:26 +00:00
this.reference = {
messageReference: {
channelID: this.channel.id,
2022-03-22 20:43:26 +00:00
messageID: this.message.id,
guildID: this.channel.guild ? this.channel.guild.id : undefined,
2022-03-22 20:43:26 +00:00
failIfNotExists: false
},
allowedMentions: {
repliedUser: false
}
};
} else if (options.type === "application") {
2022-03-22 20:43:26 +00:00
this.interaction = options.interaction;
this.args = [];
this.channel = options.interaction.channel;
this.author = this.member = options.interaction.guildID ? options.interaction.member : options.interaction.user;
if (options.interaction.data.options) {
this.options = options.interaction.data.options.reduce((obj, item) => {
obj[item.name] = item.value;
return obj;
}, {});
this.optionsArray = options.interaction.data.options;
} else {
this.options = {};
}
2022-03-22 20:43:26 +00:00
}
}
async run() {
return "It works!";
}
2022-03-22 20:43:26 +00:00
async acknowledge() {
if (this.type === "classic") {
await this.client.sendChannelTyping(this.channel.id);
2022-03-22 20:43:26 +00:00
} else {
await this.interaction.acknowledge();
}
}
static init() {
return this;
}
static description = "No description found";
static aliases = [];
static arguments = [];
static flags = [];
static requires = [];
2022-03-22 20:43:26 +00:00
static slashAllowed = true;
static directAllowed = true;
}
export default Command;