Linting
This commit is contained in:
@@ -1,16 +1,19 @@
|
||||
import { DebugBuilder } from "../../modules/debugger.mjs";
|
||||
const log = new DebugBuilder("server", "discordBot.events.guildCreate");
|
||||
import { Events } from 'discord.js';
|
||||
import { addEnabledCommands, addEnabledEventListeners } from "../discordBot.mjs";
|
||||
import { Events } from "discord.js";
|
||||
import {
|
||||
addEnabledCommands,
|
||||
addEnabledEventListeners,
|
||||
} from "../discordBot.mjs";
|
||||
|
||||
export const name = Events.GuildMemberAdd;
|
||||
|
||||
export async function execute(nodeIo, guild) {
|
||||
log.INFO("Bot has joined a new server", guild);
|
||||
log.INFO("Bot has joined a new server", guild);
|
||||
|
||||
log.DEBUG("Refreshing commands enabled");
|
||||
await addEnabledCommands(nodeIo.serverClient);
|
||||
log.DEBUG("Refreshing commands enabled");
|
||||
await addEnabledCommands(nodeIo.serverClient);
|
||||
|
||||
log.DEBUG("Refreshing events enabled");
|
||||
await addEnabledEventListeners(nodeIo.serverClient);
|
||||
}
|
||||
log.DEBUG("Refreshing events enabled");
|
||||
await addEnabledEventListeners(nodeIo.serverClient);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { DebugBuilder } from "../../modules/debugger.mjs";
|
||||
const log = new DebugBuilder("server", "discordBot.events.guildMemberAdd");
|
||||
import dotenv from 'dotenv';
|
||||
import dotenv from "dotenv";
|
||||
dotenv.config();
|
||||
import { Events } from 'discord.js';
|
||||
import { Events } from "discord.js";
|
||||
import { gptHandler } from "../modules/gptHandler.mjs";
|
||||
|
||||
const welcomeChannel = process.env.WELCOME_CHANNEL_ID; // TODO - Need to add a DB section for server configs so it's not static to one server
|
||||
@@ -10,25 +10,24 @@ const welcomeChannel = process.env.WELCOME_CHANNEL_ID; // TODO - Need to add a D
|
||||
export const name = Events.GuildMemberAdd;
|
||||
|
||||
export async function execute(nodeIo, member) {
|
||||
log.INFO("New user joined the server", member);
|
||||
let conversation = [];
|
||||
conversation.push({
|
||||
role: 'assistant',
|
||||
content: `A new user has joined the server. Their name is '<@${member.id}>'. Please welcome them to the server and remind them about the rules.`
|
||||
})
|
||||
log.INFO("New user joined the server", member);
|
||||
let conversation = [];
|
||||
conversation.push({
|
||||
role: "assistant",
|
||||
content: `A new user has joined the server. Their name is '<@${member.id}>'. Please welcome them to the server and remind them about the rules.`,
|
||||
});
|
||||
|
||||
const response = await gptHandler(conversation);
|
||||
if (response) {
|
||||
const responseMessage = response.choices[0].message.content;
|
||||
const chunkSize = 2500;
|
||||
const response = await gptHandler(conversation);
|
||||
if (response) {
|
||||
const responseMessage = response.choices[0].message.content;
|
||||
const chunkSize = 2500;
|
||||
|
||||
for (let i = 0; i < responseMessage.length; i += chunkSize) {
|
||||
const chunk = responseMessage.substring(i, i + chunkSize);
|
||||
for (let i = 0; i < responseMessage.length; i += chunkSize) {
|
||||
const chunk = responseMessage.substring(i, i + chunkSize);
|
||||
|
||||
log.DEBUG("Sending message chunk:", chunk);
|
||||
log.DEBUG("Sending message chunk:", chunk);
|
||||
|
||||
await nodeIo.serverClient.channels.cache.get(welcomeChannel).send(chunk);
|
||||
}
|
||||
await nodeIo.serverClient.channels.cache.get(welcomeChannel).send(chunk);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { DebugBuilder } from "../../modules/debugger.mjs";
|
||||
const log = new DebugBuilder("server", "discordBot.events.interactionCreate");
|
||||
import { Events } from 'discord.js';
|
||||
import { Events } from "discord.js";
|
||||
|
||||
export const name = Events.InteractionCreate;
|
||||
|
||||
@@ -22,7 +22,9 @@ export async function execute(nodeIo, interaction) {
|
||||
return;
|
||||
}
|
||||
|
||||
log.INFO(`${interaction.member.user} is running '${interaction.commandName}'`);
|
||||
log.INFO(
|
||||
`${interaction.member.user} is running '${interaction.commandName}'`,
|
||||
);
|
||||
|
||||
// Defer the initial reply if the command has the parameter set
|
||||
if (command.deferInitialReply) {
|
||||
@@ -31,4 +33,4 @@ export async function execute(nodeIo, interaction) {
|
||||
|
||||
// Execute the command
|
||||
command.execute(nodeIo, interaction);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
import { DebugBuilder } from "../../modules/debugger.mjs";
|
||||
const log = new DebugBuilder("server", "discordBot.events.messageCreate");
|
||||
import dotenv from 'dotenv';
|
||||
import dotenv from "dotenv";
|
||||
dotenv.config();
|
||||
import { Events } from 'discord.js';
|
||||
import { gptInteraction } from '../addons/gptInteraction.mjs';
|
||||
import { linkCop } from '../addons/linkCop.mjs';
|
||||
import { Events } from "discord.js";
|
||||
import { gptInteraction } from "../addons/gptInteraction.mjs";
|
||||
import { linkCop } from "../addons/linkCop.mjs";
|
||||
|
||||
const IGNORED_CHANNELS = process.env.IGNORED_CHANNEL_IDS.split(',');
|
||||
const IGNORED_CHANNELS = process.env.IGNORED_CHANNEL_IDS.split(",");
|
||||
|
||||
export const name = Events.MessageCreate;
|
||||
|
||||
export async function execute(nodeIo, message) {
|
||||
// Ignore ignored channels
|
||||
if (IGNORED_CHANNELS.includes(message.channel.id)) return;
|
||||
// Ignore ignored channels
|
||||
if (IGNORED_CHANNELS.includes(message.channel.id)) return;
|
||||
|
||||
// Ignore messages from a bot
|
||||
if (message.author.bot) return;
|
||||
// Ignore messages from a bot
|
||||
if (message.author.bot) return;
|
||||
|
||||
log.INFO("Message create", message);
|
||||
log.INFO("Message create", message);
|
||||
|
||||
// Check if the message mentions the bot
|
||||
if (message.mentions.users.has(nodeIo.serverClient.user.id)) {
|
||||
return await gptInteraction(nodeIo, message);
|
||||
}
|
||||
// Check if the message mentions the bot
|
||||
if (message.mentions.users.has(nodeIo.serverClient.user.id)) {
|
||||
return await gptInteraction(nodeIo, message);
|
||||
}
|
||||
|
||||
// Check if the message contains a link in a channel it shouldn't
|
||||
if (await linkCop(nodeIo, message)) return;
|
||||
}
|
||||
// Check if the message contains a link in a channel it shouldn't
|
||||
if (await linkCop(nodeIo, message)) return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user