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

feat(qotd): Add banned key words (#75) #84

Merged
merged 2 commits into from
Feb 13, 2024
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ All notable changes to this project will be documented in this file.

❄️ Twitch: Now can ignore some categories for the Category Change notification - [[#75](https://github.com/adroidea/bot/issues/75)]

❄️ QotD: Add banned key words - [[#78](https://github.com/adroidea/bot/issues/78)]

### 🧱 Changed

### 🚮 Removed
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
]
},
"dependencies": {
"adroi.d.ea": "^1.0.9",
"adroi.d.ea": "^1.1.0",
"ansis": "^1.5.5",
"bullmq": "^3.12.0",
"discord.js": "^14.14.1",
Expand Down
4 changes: 4 additions & 0 deletions src/modules/qotd/commands/qotd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export default {
if (qotd.blacklist?.includes(interaction.user.id)) throw CustomErrors.BlacklistedUserError;

const question = interaction.options.getString('question', true);

if (qotd.bannedWords?.some(word => new RegExp(word, 'i').test(question)))
throw CustomErrors.BannedWordError;

const author = interaction.options.getUser('auteur');
const user = (interaction.member as GuildMember).user;

Expand Down
3 changes: 2 additions & 1 deletion src/modules/qotd/models/qotd.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export const qotdSchema = new mongoose.Schema<IQOTDModule>({
pingedRoleId: String,
blacklist: [String],
whitelist: [String],
questionsThreshold: Number
questionsThreshold: Number,
bannedWords: [String]
});

export const questionsSchema = new mongoose.Schema<IQuestions>({
Expand Down
3 changes: 2 additions & 1 deletion src/utils/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export const CustomErrors = {
// QOtD related err //
////////////////////////////////////////////////////
QOtDeDisabledError: new CustomError('Les QdJ ne sont pas activées sur ce serveur.'),
BlacklistedUserError: new CustomError('Les requêtes personnalisées sont désactivés pour toi.'),
BlacklistedUserError: new CustomError('Tu es blacklisté, tu ne peux pas proposer de question.'),
BannedWordError: new CustomError('Ta question contient un mot interdit.'),

////////////////////////////////////////////////////
// Twitch related err //
Expand Down
Loading