Skip to content
This repository was archived by the owner on Oct 31, 2022. It is now read-only.

Commit 2069593

Browse files
author
Alexandre Carvalho
committed
Swiched from discord.js to eris
1 parent f30bc01 commit 2069593

File tree

5 files changed

+2110
-2402
lines changed

5 files changed

+2110
-2402
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules
2+
.env

bot.js

Lines changed: 29 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,32 @@
1-
const {
2-
Client,
3-
MessageEmbed,
4-
} = require('discord.js');
5-
const {
6-
prefix,
7-
token,
8-
} = require('./config.json');
9-
const client = new Client({
10-
intents: ['GUILDS', 'GUILD_MESSAGES'],
11-
});
12-
const fetch = require('node-fetch').default;
1+
import {} from 'dotenv/config'
2+
import Eris from 'eris'
3+
const bot = new Eris(process.env.TOKEN)
134
const ENDPOINTS = {
14-
shiba: 'http://shibe.online/api/shibes?count=1&urls=true&httpsUrls=true',
15-
};
16-
17-
client.once('ready', () => {
18-
console.log('Ready!');
19-
});
20-
21-
// commands
22-
client.on('message', message => {
23-
if (!message.content.startsWith(prefix) || message.author.bot) return;
24-
25-
const args = message.content.slice(prefix.length).trim().split(/ +/);
26-
const command = args.shift().toLowerCase();
27-
const channel = client.channels.cache.get(message.channel.id);
28-
if (command === 'shiba') {
29-
fetch(ENDPOINTS.shiba, {
30-
method: 'GET',
31-
})
32-
.then(res => res.json())
33-
.then(([data]) => {
34-
const embed = new MessageEmbed()
35-
.setColor('#E67E22')
36-
.setImage(data)
37-
.setTitle('Shiba!')
38-
.setURL(data);
39-
channel.send({
40-
embeds: [embed],
41-
});
42-
});
43-
}
5+
shiba: 'http://shibe.online/api/shibes?count=1&urls=true&httpsUrls=true',
6+
}
7+
import fetch from 'node-fetch';
8+
bot.on("ready", () => {
9+
console.log("Ready!")
4410
});
4511

46-
client.login(token);
12+
bot.on("messageCreate", (msg => {
13+
if (msg.content === "s.shiba") {
14+
fetch(ENDPOINTS.shiba, {
15+
method: 'GET',
16+
})
17+
.then(res => res.json())
18+
.then(([data]) => {
19+
bot.createMessage(msg.channel.id, {
20+
embed: {
21+
title: "Shiba!",
22+
url: data.url,
23+
color: 0xE67E22,
24+
image: {
25+
url: data
26+
}
27+
}
28+
})
29+
})
30+
}
31+
}))
32+
bot.connect()

config.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)