This commit is contained in:
10
src/commands/prefix/fetchApk/fetch.ts
Normal file
10
src/commands/prefix/fetchApk/fetch.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Client, Message } from "discord.js";
|
||||
import { fetchApk } from "@/services/fetchApk";
|
||||
|
||||
export const name = "apk";
|
||||
export const description = "Fetch apk";
|
||||
|
||||
export async function execute(client: Client, message: Message, args: string[]) {
|
||||
const version = args[0];
|
||||
await fetchApk(version, message);
|
||||
}
|
||||
24
src/commands/prefix/index.ts
Normal file
24
src/commands/prefix/index.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Client, Collection } from "discord.js";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
import type { prefixCommand } from "@/types/discord.js";
|
||||
|
||||
export function ActiveAllPrefixCommands(client: Client) {
|
||||
const commandFolder = path.join(__dirname);
|
||||
client.prefix = new Collection<string, prefixCommand>();
|
||||
for (const folder of fs.readdirSync(commandFolder)) {
|
||||
const folderPath = path.join(commandFolder, folder);
|
||||
if (!fs.statSync(folderPath).isDirectory()) continue;
|
||||
|
||||
const commandFiles = fs.readdirSync(folderPath).filter(file => file.endsWith(".ts"));
|
||||
for (const file of commandFiles) {
|
||||
const command = require(path.join(folderPath, file));
|
||||
if (!command.name || typeof command.execute !== "function") {
|
||||
console.log(`Prefix command at ${path.join(folderPath, file)} is missing a name or execute function`);
|
||||
continue;
|
||||
}
|
||||
// console.log(`Prefix command ${command.name} loaded`);
|
||||
client.prefix.set(command.name, command);
|
||||
}
|
||||
}
|
||||
}
|
||||
10
src/commands/prefix/ping/ping.ts
Normal file
10
src/commands/prefix/ping/ping.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Message, Client } from "discord.js";
|
||||
|
||||
export const name = "ping";
|
||||
export const description = "Kiểm tra thời gian phản hồi của bot";
|
||||
|
||||
export async function execute(client: Client, message: Message, args: string[]) {
|
||||
const sent = await message.reply('Pong!');
|
||||
const latency = sent.createdTimestamp - message.createdTimestamp;
|
||||
await sent.edit(`Pong! \`${latency}ms\``);
|
||||
}
|
||||
Reference in New Issue
Block a user