-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
44 lines (37 loc) · 1.34 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Discord MapItBot
// Created by Marcus Perry April 1, 2022
const dotenv = require('dotenv');
const fs = require('node:fs');
const {Client, Intents, MessageEmbed, Message} = require('discord.js');
const {token} = require('./config.json');
const {gmaptoken} = require('./config.json')
const url = require('url')
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES
]
});
const { setDefaultResultOrder } = require('node:dns');
// client.commands = new Collection();
// const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
dotenv.config();
client.on('ready', () => {
console.log('MapIt has been successfully initialized.');
});
client.on("messageCreate", (message) => {
if (message.content.includes('!map')) {
let sliceMsg = message.content.slice(4);
let trimMsg = sliceMsg.trim();
let toMap = encodeURI(trimMsg);
//URImsg = encodeURIComponent() //must separate out !map from rest of message
let mapEmbed = {
url: `https://maps.googleapis.com/maps/api/staticmap?center=${toMap}&zoom=8&size=640x640&key=${gmaptoken}`,
image: {
url: `https://maps.googleapis.com/maps/api/staticmap?center=${toMap}&zoom=8&size=640x640&key=${gmaptoken}`
}
};
message.channel.send({ embeds: [mapEmbed] });
}
});
client.login(token);