|
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) |
13 | 4 | 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!") |
44 | 10 | });
|
45 | 11 |
|
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() |
0 commit comments