Skip to content

Commit

Permalink
feat(qotd): Add banned key words (#75)
Browse files Browse the repository at this point in the history
Merge pull request #84 from adroidea/feat/qotd/78-add-banned-key-words
  • Loading branch information
adan-ea authored Feb 13, 2024
2 parents 72dac3f + 2eb1a89 commit a1a633f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
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

0 comments on commit a1a633f

Please sign in to comment.