forked from Kmyming/mastodon-discord-webhook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
53 lines (44 loc) · 1.71 KB
/
bot.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
45
46
47
48
49
50
51
52
53
// Require the necessary discord.js classes
const { Client, Events, GatewayIntentBits, EmbedBuilder, PermissionsBitField, Permissions } = require('discord.js');
// Create a new client instance
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
const Mastodon = require('mastodon-api');//import masotodn api client
const ENV = require('dotenv');//import env var
const prefix = '!';
ENV.config(); //config env var
// When the client is ready, run this code (only once)
// We use 'c' for the event parameter to keep it separate from the already defined 'client'
client.on("ready", c => {
console.log(`Ready! Logged in as ${c.user.tag}`);
});
// Log in to Discord with your client's token
client.login(process.env.bot_token);
const M = new Mastodon({
access_token: process.env.ACCESS_TOKEN,
//client_key: process.env.CLIENT_KEY,
//client_secret:process.env.CLIENT_SECRET,
api_url: "https://tinkertofu.com/api/v1/",
});
client.on('messageCreate', (message)=>{
console.log('received message');
if (message.content.startsWith(prefix)){
if (message.author.bot) return;
if(message.content === '!hello'){
message.channel.send('Hello!');
console.log('sent message');
}
}
/*
if (message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
//Message Array
const messageArray = message.content.split("");
const argument = messageArray.slice(1);
const cmd = messageArray[0];
//COMMANDS
if (command === 'hello'){
message.channel.send('Hello!');
console.log('sent message');
}*/
})