Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change forbidden channels to allowed ones #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions events/messageCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { getChatCompletion } = require('../openAi');
const db = require('../DB');
const {
getQuestion,
isAskingInForbiddenChannel,
isAskingInAnAllowedChannel,
isAskingLeni,
} = require('../utils/chat-utils.js');

Expand All @@ -17,7 +17,7 @@ module.exports = {
if (!isAskingLeni(startMessage)) {
return false;
}
if (isAskingInForbiddenChannel(message)) {
if (!isAskingInAnAllowedChannel(message)) {
return message.channel?.send(
'Please direct your questions to the classroom channel exclusively. Thank you. 👽',
);
Expand Down
13 changes: 4 additions & 9 deletions utils/chat-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@ function isAskingLeni(message) {
);
}

// eslint-disable-next-line no-unused-vars
function isAskingInForbiddenChannel(message) {
function isAskingInAnAllowedChannel(message) {
return (
process.env.FORBIDDEN_CHANNEL_IDS.includes(message?.channelId) ||
process.env.FORBIDDEN_CHANNEL_IDS.includes(message?.channel?.parentId)
process.env.ALLOWED_CHANNEL_IDS.includes(message?.channelId) ||
process.env.ALLOWED_CHANNEL_IDS.includes(message?.channel?.parentId)
);
// if (!process.env.CLASSROOM_IDS) {
// return false;
// }
// return process.env.CLASSROOM_IDS.some(id => id === message.channelID);
}

function getQuestion(message) {
Expand All @@ -22,6 +17,6 @@ function getQuestion(message) {

module.exports = {
isAskingLeni,
isAskingInForbiddenChannel,
isAskingInAnAllowedChannel,
getQuestion,
};