This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
.env
|
||||
node_modules
|
||||
.history
|
||||
dist/
|
||||
@@ -5,11 +5,11 @@
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"dev": "tsx watch src/index.ts",
|
||||
"start": "tsx src/index.ts",
|
||||
"build": "tsc"
|
||||
"build": "tsc",
|
||||
"start": "node -r module-alias/register dist/index.js"
|
||||
},
|
||||
"_moduleAliases": {
|
||||
"@": "src"
|
||||
"@": "dist"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
import { Client, ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
import { fetchApk } from "@/services/fetchApk";
|
||||
export const data = new SlashCommandBuilder()
|
||||
.setName("apk")
|
||||
.setDescription("Fetch apk")
|
||||
.addStringOption((option) => option
|
||||
.setName("version")
|
||||
.setDescription("Version of apk")
|
||||
.setRequired(true));
|
||||
export async function execute(client, interaction) {
|
||||
const version = interaction.options.getString("version");
|
||||
await fetchApk(version, interaction);
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
import { Client, Collection, REST, Routes } from "discord.js";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
import { config } from "@/config";
|
||||
export async function ActiveAllSlashCommands(client) {
|
||||
client.slash = new Collection();
|
||||
const commandFolder = path.join(__dirname);
|
||||
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.data?.name || typeof command.execute !== "function") {
|
||||
console.log(`Slash command at ${path.join(folderPath, file)} is missing a name or execute function`);
|
||||
continue;
|
||||
}
|
||||
client.slash.set(command.data.name, command);
|
||||
}
|
||||
}
|
||||
}
|
||||
const rest = new REST({ version: '10' }).setToken(config.DISCORD_TOKEN);
|
||||
export async function registerCommandsAll() {
|
||||
const commands = [];
|
||||
const commandFolder = path.join(__dirname);
|
||||
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.data?.name || typeof command.execute !== "function")
|
||||
continue;
|
||||
commands.push(command.data.toJSON());
|
||||
}
|
||||
}
|
||||
try {
|
||||
console.log('Started refreshing application (/) commands.');
|
||||
const data = await rest.put(Routes.applicationCommands(config.DISCORD_CLIENT_ID), { body: commands });
|
||||
console.log(`Successfully reloaded ${data.length} application (/) commands.`);
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import { ChatInputCommandInteraction, Client, SlashCommandBuilder } from "discord.js";
|
||||
export const data = new SlashCommandBuilder()
|
||||
.setName("ping")
|
||||
.setDescription("Replies with pong!");
|
||||
export async function execute(client, interaction) {
|
||||
await interaction.reply("Pong!");
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
import { ActivityType, Client, Events, PresenceUpdateStatus } from "discord.js";
|
||||
export const name = Events.ClientReady;
|
||||
export const once = true;
|
||||
export async function execute(client) {
|
||||
if (!client.user || !client.application)
|
||||
return;
|
||||
console.log(`🚩Logged in as ${client.user.tag}!`);
|
||||
const activityTypeMap = {
|
||||
'PLAYING': ActivityType.Playing,
|
||||
'WATCHING': ActivityType.Watching,
|
||||
'LISTENING': ActivityType.Listening,
|
||||
'STREAMING': ActivityType.Streaming,
|
||||
'COMPETING': ActivityType.Competing
|
||||
};
|
||||
const statusMap = {
|
||||
'online': PresenceUpdateStatus.Online,
|
||||
'idle': PresenceUpdateStatus.Idle,
|
||||
'dnd': PresenceUpdateStatus.DoNotDisturb,
|
||||
'invisible': PresenceUpdateStatus.Invisible
|
||||
};
|
||||
const statusType = process.env.BOT_STATUS || 'online';
|
||||
const activityType = process.env.ACTIVITY_TYPE || 'PLAYING';
|
||||
const activityName = process.env.ACTIVITY_NAME || 'Shoudo sakusen jikkou!';
|
||||
client.user.setPresence({
|
||||
status: statusMap[statusType],
|
||||
activities: [{
|
||||
name: activityName,
|
||||
type: activityTypeMap[activityType]
|
||||
}]
|
||||
});
|
||||
console.log(`🗿Bot status set to: ${statusType}`);
|
||||
console.log(`👨🎤Activity set to: ${activityType} ${activityName}`);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'module-alias/register'
|
||||
import { Client, GatewayIntentBits, Partials } from "discord.js";
|
||||
import { config } from "./config";
|
||||
import ActiveAllEvents from "./events";
|
||||
import { ActiveAllPrefixCommands, ActiveAllSlashCommands } from "./commands";
|
||||
import { config } from "@/config";
|
||||
import ActiveAllEvents from "@/events";
|
||||
import { ActiveAllPrefixCommands, ActiveAllSlashCommands } from "@/commands";
|
||||
|
||||
console.log("🔥 Starting bot...")
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2022",
|
||||
"module": "CommonJS",
|
||||
"moduleResolution": "node",
|
||||
"esModuleInterop": true,
|
||||
"allowJs": true,
|
||||
@@ -12,24 +13,13 @@
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strictNullChecks": true,
|
||||
"verbatimModuleSyntax": false,
|
||||
"baseUrl": "src",
|
||||
"module": "CommonJS",
|
||||
"moduleDetection": "force",
|
||||
"isolatedModules": true,
|
||||
"strict": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noImplicitOverride": true,
|
||||
// "noEmit": true,
|
||||
"outDir": "dist",
|
||||
"baseUrl": "./src",
|
||||
"outDir": "./dist",
|
||||
"lib": ["es2022"],
|
||||
"paths": {
|
||||
"@/*": ["*"]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"src/**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user