car
This commit is contained in:
parent
4c598e7e64
commit
ec9315fe83
|
@ -1,7 +1,6 @@
|
|||
/* (TEMPLATE )Bot config file; edit this to your liking */
|
||||
/* Make sure to rename this to config.ts */
|
||||
export default
|
||||
{
|
||||
export default {
|
||||
prefix: "X",
|
||||
token: "X",
|
||||
owner: "X"
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
import { Message } from "concordia";
|
||||
|
||||
export default
|
||||
{
|
||||
export default {
|
||||
name: 'goodnight',
|
||||
description: 'i lost hours of sleep to ts',
|
||||
execute(msg: Message, args: string[])
|
||||
{
|
||||
execute(msg: Message, args: string[]) {
|
||||
msg.reply('good night.');
|
||||
}
|
||||
}
|
||||
|
|
28
src/index.ts
28
src/index.ts
|
@ -4,11 +4,9 @@ import cfg from "../config";
|
|||
import { ActivityType, Client, Collection, Message } from "concordia";
|
||||
import fs from "node:fs"
|
||||
|
||||
class CommandClient extends Client
|
||||
{
|
||||
class CommandClient extends Client {
|
||||
commands: Collection<string, any>;
|
||||
constructor()
|
||||
{
|
||||
constructor() {
|
||||
super();
|
||||
this.commands = new Collection<string, any>();
|
||||
}
|
||||
|
@ -18,8 +16,7 @@ const client = new CommandClient();
|
|||
|
||||
/* Command Handling */
|
||||
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
|
||||
for (const file of commandFiles)
|
||||
{
|
||||
for (const file of commandFiles) {
|
||||
const command = require(`./commands/${file}`).default;
|
||||
// set new item in collection with key as command name & value as exported module
|
||||
client.commands.set(command.name, command);
|
||||
|
@ -28,19 +25,16 @@ for (const file of commandFiles)
|
|||
|
||||
|
||||
/* Bot start-up & continued behaviour */
|
||||
function onReady(): void
|
||||
{
|
||||
client.user!.setPresence
|
||||
({
|
||||
activity: { name: 'with my balls.'},
|
||||
function onReady(): void {
|
||||
client.user!.setPresence({
|
||||
activity: { name: 'with my balls.' },
|
||||
status: 'idle'
|
||||
});
|
||||
console.log("Logged in!");
|
||||
}
|
||||
|
||||
function onMessage(msg: Message): void
|
||||
{
|
||||
if ( msg.author.bot || !msg.content.startsWith(cfg.prefix) )
|
||||
function onMessage(msg: Message): void {
|
||||
if (msg.author.bot || !msg.content.startsWith(cfg.prefix))
|
||||
return;
|
||||
|
||||
const args: string[] = msg.content.slice(cfg.prefix.length).trim().split(/ +/);
|
||||
|
@ -48,12 +42,10 @@ function onMessage(msg: Message): void
|
|||
|
||||
if (!client.commands.has(command)) return;
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
client.commands.get(command).execute(msg, args);
|
||||
}
|
||||
catch (error)
|
||||
{
|
||||
catch (error) {
|
||||
console.error(error);
|
||||
msg.reply('There was an error...');
|
||||
}
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
{
|
||||
"compilerOptions":
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2020",
|
||||
"module": "commonjs",
|
||||
"outDir": "build/",
|
||||
"esModuleInterop": true,
|
||||
"strict": true
|
||||
},
|
||||
|
||||
"include":
|
||||
[
|
||||
"include": [
|
||||
"src/**/*",
|
||||
"config.json"
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue