Skip to content

Commit be3638d

Browse files
committed
first commit
0 parents  commit be3638d

File tree

9 files changed

+122
-0
lines changed

9 files changed

+122
-0
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
TOKEN=
2+
PREFIX=

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
package-lock.json
2+
node_modules

LICENSE

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
ISC License
2+
3+
Copyright (c) [year] [fullname]
4+
5+
Permission to use, copy, modify, and/or distribute this software for any
6+
purpose with or without fee is hereby granted, provided that the above
7+
copyright notice and this permission notice appear in all copies.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15+
PERFORMANCE OF THIS SOFTWARE.

commands/ping.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const { Client, Message } = require('guilded.js');
2+
3+
module.exports = {
4+
name: 'ping',
5+
description: 'Pings the bot.',
6+
/**
7+
* @param {Client} client
8+
* @param {Message} message
9+
* @param {String[]} args
10+
*/
11+
run: async(client, message, args) => {
12+
message.send('Loading data...').then( async (msg) => {
13+
msg.delete();
14+
return message.send(`🏓Latency is ${msg._createdAt - message._createdAt}ms.`);
15+
});
16+
}
17+
}

events/messageCreated.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const client = require('../index');
2+
3+
client.on('messageCreated', async (message) => {
4+
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);
7+
8+
const command = client.commands.get(cmd.toLowerCase()) || client.commands.find(c => c.aliases?.includes(cmd.toLowerCase()));
9+
10+
if (!command) return;
11+
await command.run(client, message, args);
12+
})

events/ready.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const client = require('../index');
2+
3+
client.on('ready', () => {
4+
console.log(`Logged in as ${client.user.name}!`);
5+
});

handler/index.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const { glob } = require("glob");
2+
const { promisify } = require("util");
3+
const { Client } = require("guilded.js");
4+
5+
const globPromise = promisify(glob);
6+
7+
/**
8+
* @param {Client} client
9+
*/
10+
module.exports = async (client) => {
11+
12+
// Commands
13+
const commandFiles = await globPromise(`commands/*.js`);
14+
commandFiles.map((value) => {
15+
const file = require('../' + value);
16+
const splitted = value.split("/");
17+
const directory = splitted[splitted.length - 2];
18+
19+
if (file.name) {
20+
const properties = { directory, ...file };
21+
client.commands.set(file.name, properties);
22+
}
23+
});
24+
25+
// Events
26+
const eventFiles = await globPromise(`events/*.js`);
27+
eventFiles.map((value) => require('../' + value));
28+
29+
}

index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const { Client } = require('guilded.js');
2+
const { Collection } = require('@discordjs/collection');
3+
require('dotenv').config();
4+
5+
const client = new Client({
6+
token: process.env.TOKEN
7+
});
8+
9+
module.exports = client;
10+
11+
// Global Variables
12+
client.commands = new Collection();
13+
14+
require('./handler')(client);
15+
16+
client.login();

package.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "gjs-base-handler",
3+
"version": "1.0.0",
4+
"description": "A guilded.js base handler for bots!",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [
10+
"guilded",
11+
"guildedjs",
12+
"guilded.js",
13+
"guilded",
14+
"bot"
15+
],
16+
"author": "MixDevCode",
17+
"license": "ISC",
18+
"dependencies": {
19+
"@discordjs/collection": "^1.3.0",
20+
"dotenv": "^16.0.3",
21+
"glob": "^8.1.0",
22+
"guilded.js": "^0.17.1"
23+
}
24+
}

0 commit comments

Comments
 (0)