Skip to content

Commit 6d8571d

Browse files
committed
updated gjs ver + some changes
1 parent 96ca018 commit 6d8571d

File tree

5 files changed

+21
-14
lines changed

5 files changed

+21
-14
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = {
99
* @param {String[]} args
1010
*/
1111
run: async(client, message, args) => {
12-
message.send('Loading data...').then( async (msg) => {
12+
message.send('Loading data...').then(async (msg) => {
1313
msg.delete();
1414
return message.send(`🏓Latency is ${msg._createdAt - message._createdAt}ms.`);
1515
});

events/messageCreated.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
const client = require('../index');
22

33
client.on('messageCreated', async (message) => {
4+
45
if (message.author && message.author.raw.type == 'bot') return;
5-
if (!message.content.toLowerCase().startsWith(process.env.PREFIX)) return;
6-
const [cmd, ...args] = message.content.substring(process.env.PREFIX.length).split(/ +/g);
6+
7+
if (!message.content.toLowerCase().startsWith(process.env["PREFIX"])) return;
8+
9+
const [cmd, ...args] = message.content.substring(process.env["PREFIX"].length).split(/ +/g);
710

811
const command = client.commands.get(cmd.toLowerCase()) || client.commands.find(c => c.aliases?.includes(cmd.toLowerCase()));
9-
12+
1013
if (!command) return;
14+
15+
message.channel ??= await client.channels.fetch(message.channelId);
1116
await command.run(client, message, args);
1217
})

handler/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ const globPromise = promisify(glob);
1010
module.exports = async (client) => {
1111

1212
// Commands
13-
const commandFiles = await globPromise(`commands/*.js`);
13+
const commandFiles = await globPromise(`${process.cwd()}/commands/**/*.js`);
1414
commandFiles.map((value) => {
15-
const file = require('../' + value);
15+
const file = require(value);
1616
const splitted = value.split("/");
1717
const directory = splitted[splitted.length - 2];
1818

@@ -23,7 +23,7 @@ module.exports = async (client) => {
2323
});
2424

2525
// Events
26-
const eventFiles = await globPromise(`events/*.js`);
27-
eventFiles.map((value) => require('../' + value));
26+
const eventFiles = await globPromise(`${process.cwd()}/events/*.js`);
27+
eventFiles.map((value) => require(value));
2828

2929
}

index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
const { Client } = require('guilded.js');
21
require('dotenv').config();
2+
const { Client } = require('guilded.js');
3+
const { Collection } = require('@discordjs/collection');
34

45
const client = new Client({
5-
token: process.env.TOKEN
6+
token: process.env["TOKEN"]
67
});
78

89
module.exports = client;
910

1011
// Global Variables
11-
client.commands = new Map();
12+
client.commands = new Collection();
1213

1314
require('./handler')(client);
1415

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gjs-base-handler",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "A guilded.js base handler for bots!",
55
"main": "index.js",
66
"scripts": {
@@ -16,8 +16,9 @@
1616
"author": "MixDevCode",
1717
"license": "ISC",
1818
"dependencies": {
19+
"@discordjs/collection": "^1.4.0",
1920
"dotenv": "^16.0.3",
20-
"glob": "^8.1.0",
21-
"guilded.js": "^0.17.1"
21+
"glob": "^7.1.7",
22+
"guilded.js": "^0.20.0"
2223
}
2324
}

0 commit comments

Comments
 (0)