@gary50613/discord.js-command-handler
Advanced tools
Comparing version 2.5.3 to 2.6.0
@@ -78,3 +78,3 @@ # djs-command-handler | ||
// 執行指令的方法 | ||
execute(message, args, member, guild) { | ||
execute(bot, message, args) { | ||
// 就像寫 discord.js 一樣! | ||
@@ -137,3 +137,3 @@ message.reply('pong!') | ||
// 執行指令的方法 | ||
public async execute(bot: Client, message: Message, args: string[], member: GuildMember, guild: Guild) { | ||
public async execute(bot: Client, message: Message, args: string[]) { | ||
// 就像寫 discord.js 一樣! | ||
@@ -140,0 +140,0 @@ message.reply("pong!") |
{ | ||
"name": "@gary50613/discord.js-command-handler", | ||
"version": "2.5.3", | ||
"version": "2.6.0", | ||
"description": "simple discord.js command handler", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -81,3 +81,3 @@ # discord.js-command-handler | ||
// execute function to call | ||
async execute(bot, message, args, member, guild) { | ||
async execute(bot, message, args) { | ||
// just write like normal discord.js | ||
@@ -139,3 +139,3 @@ message.reply('pong!') | ||
public async execute(bot: Client, message: Message, args: string[], member: GuildMember, guild: Guild) { | ||
public async execute(bot: Client, message: Message, args: string[]) { | ||
// just write like normal discord.js | ||
@@ -142,0 +142,0 @@ message.reply("pong!") |
@@ -10,3 +10,3 @@ class Command { | ||
async execute(bot, message, args, member, guild) { | ||
async execute(bot, message, args) { | ||
} | ||
@@ -13,0 +13,0 @@ } |
@@ -8,4 +8,3 @@ class Interaction { | ||
async execute(bot, interaction, options, member) { | ||
async execute(bot, interaction, options) { | ||
} | ||
@@ -12,0 +11,0 @@ } |
@@ -10,13 +10,16 @@ const { MessageEmbed } = require("discord.js") | ||
this.message = message | ||
this.webhook = this.getWebhook() | ||
} | ||
edit = async (content) => { | ||
async edit(content) { | ||
let data = this.buildInteractionData(content) | ||
await this.bot.api.webhooks(this.bot?.user?.id, this.interaction?.token)?.messages(this.message.id).patch({data}) | ||
await this.webhook?.patch({data}) | ||
return this.message | ||
return this | ||
} | ||
delete = async () => { | ||
await this.bot.api.webhooks(this.bot?.user?.id, this.interaction?.token)?.messages(this.message?.id).delete() | ||
async delete() { | ||
await this.webhook?.delete() | ||
return undefined | ||
} | ||
@@ -31,4 +34,9 @@ | ||
} | ||
getWebhook() { | ||
return this.bot?.api?.webhooks(this.bot?.user?.id, this.interaction?.token) | ||
?.messages(this.message.id) | ||
} | ||
} | ||
module.exports = InteractionResponse |
@@ -32,3 +32,3 @@ const Group = require("../base/Group") | ||
try { | ||
bot.commands.get(command)?.execute(bot, m, args, m?.member, m?.guild) | ||
bot.commands.get(command)?.execute(bot, m, args) | ||
.then(() => this.emit("execute", bot.commands.get(command), m)) | ||
@@ -35,0 +35,0 @@ .catch((e) => this.emit("promiseError", e, bot.commands.get(command), m)) |
@@ -17,3 +17,3 @@ const Interaction = require("../base/Interaction") | ||
async init(bot, options) { | ||
async init(bot) { | ||
this.interactions.forEach(c => this._createCommand(c)) | ||
@@ -25,4 +25,4 @@ | ||
if(executor) { | ||
let handler = new InteractionHandler(bot, interaction) | ||
try { | ||
let handler = new InteractionHandler(bot, interaction) | ||
executor.execute(bot, handler, interaction?.data?.options) | ||
@@ -29,0 +29,0 @@ .then(() => this.emit("execute", executor, handler)) |
@@ -14,3 +14,3 @@ const Command = require("../../src/base/Command"); | ||
async execute(bot, message, args, member, guild) { | ||
async execute(bot, message, args) { | ||
message.reply('pong!') | ||
@@ -17,0 +17,0 @@ } |
@@ -36,3 +36,3 @@ import { Message, MessageEmbed, Client, PermissionResolvable, GuildMember, Guild } from "discord.js" | ||
public constructor(name: string, description: string, usage: string, group: string, alias?: string[]) | ||
public execute(bot: Client, message: Message, args: string[], member: GuildMember, guild: Guild): Promise<any> | ||
public execute(bot: Client, message: Message, args: string[]): Promise<any> | ||
} | ||
@@ -53,3 +53,3 @@ | ||
public constructor(name: string, description: string, options?: any[]) | ||
public execute(bot: Client, interaction: InteractionHandler, options: any, member: GuildMember): Promise<any> | ||
public execute(bot: Client, interaction: InteractionHandler, options: any): Promise<any> | ||
} | ||
@@ -60,5 +60,7 @@ | ||
public interaction: any; | ||
public message: any | ||
public edit(content: any): Promise<any> | ||
public message: any; | ||
public webhook: any; | ||
public edit(content: any): Promise<this> | ||
public delete(): Promise<void> | ||
public getWebhook(): any | ||
public buildInteractionData(content: any): InteractionMessageContent | ||
@@ -65,0 +67,0 @@ public constructor(bot: Client, interaction: any, message: any) |
568
29802