/
discordServer.js
46 lines (42 loc) · 1.42 KB
/
discordServer.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
const { Client, GatewayIntentBits } = require("discord.js");
const getChannel = require("./getChannel");
const getEmbed = require("./getEmbed");
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
],
});
client.once("ready", async () => {
try {
console.info(`Logged in as ${client.user.tag}`);
const turnsChannel = await getChannel(client, "turns");
if (turnsChannel) {
const messageData = await turnsChannel.messages.fetch({ limit: 1 });
const message = messageData.first();
const embed = await getEmbed(client);
const embedData = { embeds: [embed] };
if (!message) {
await turnsChannel.send(embedData);
console.info("Sent message");
} else {
await message.edit(embedData);
console.info("Edited message");
}
// const generalChannel = await getChannel(client, "general", false);
// if (generalChannel) {
// const tyson = await client.users.fetch(process.env.DISCORD_TYSON_ID);
// if (tyson) {
// generalChannel.send(
// `Confirmed Sons of the Forest has been loaded. Waiting for ${tyson.toString()} to start game.`
// );
// }
// }
}
} catch (err) {
console.error(`!!Server error: ${err.message}`);
}
});
client.login(process.env.DISCORD_BOT_TOKEN);