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

Context menu button, Ban Spammer #548

Open
wants to merge 71 commits into
base: main
Choose a base branch
from

Conversation

Mclilzee
Copy link
Contributor

Because

Phishing links spam is an ever-increasing occurrence on discord. The mod team have to keep banning these users with the same message so that they know how to contact us if they wish to rejoin the server.

This PR will automate that with a click of a button.

This PR

  • Adds context menu button to ban spam user
  • Logs the ban in the appropriate channel
  • Sends the user a contact information of why they were banned, and how to contact us once they recover their account if DM is not set to private.

Issue

Closes #504

Additional Information

Make sure to change the config.js moderationLog ID to the channel ID of your test server to see the log messages while testing.

There are currently some duplication of functions in some of the other services, I think it would be a good idea to move those to utils. Another duplication happen is with the tests, There is a buildInteraction function in test utils but that one is made for a specific purpose only, I would need to change it and refactor all the tests that calls it in order to generalize it to be used by these new tests. I didn't want this PR to be too big and include those refactors. So I included some create interaction mocks functions in the test files.

Let me know how would you like to proceed with the refactors.

Pull Request Requirements

  • I have thoroughly read and understand The Odin Project Contributing Guide
  • The title of this PR follows the location of change: brief description of change format, e.g. Callbacks command: Update verbiage
  • The Because section summarizes the reason for this PR
  • The This PR section has a bullet point list describing the changes in this PR
  • If this PR addresses an open issue, it is linked in the Issue section
  • If this PR adds new features or functionality, I have added new tests
  • If applicable, I have ensured all tests related to any command files included in this PR pass, and/or all snapshots are up to date

@Mclilzee Mclilzee changed the title Automated spam ban context menu button Context menu button, Ban Spammer Jul 1, 2024
services/spam-ban/spam-banning.service.js Outdated Show resolved Hide resolved
let reply;

if (!message.member) {
message.react("❌");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming we're reacting to the banned message? So this reaction will be done on a message in a public channel? Not sure we'd want that, but do confirm with others though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The button will be mainly used on automod messages that are blocked and logged, Which only staff can see. We wont be using this for messages that automod fails to block or doesnt delete. We will use manual modding to make sure that any left over spam msgs will be deleted by us.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so this command is only for the automod messages. Isn't automod a bot though? Won't message.author.bot always return true? How are we able to get the offending user's id from an automod message? I'm drawing blanks on the documentation, so some links could be helpful 😅

I definitely should set up automod in a dummy server to test this myself instead of bombarding this PR lol

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are valid questions which I myself had, and made up an environment to explore. To my surprise however is that the Autobot logs actually act as if those message were posted by the user. message.author is actually the user who's message is blocked by Automod. Yeah certainly set up an environment and test things out

services/spam-ban/spam-banning.service.js Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++ for these tests

services/spam-ban/spam-banning.service.js Outdated Show resolved Hide resolved
config.js Outdated
@@ -13,6 +13,7 @@ const config = {
gettingHiredChannelId: process.env.DISCORD_GETTING_HIRED_CHANNEL_ID,
botSpamPlaygroundChannelId: '513125912070455296',
FAQChannelId: '823266307293839401',
moderationLog: '922520585018433536'
Copy link
Contributor

@Asartea Asartea Jul 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presuming (based on context), that this is an channel ID, shouldn't this be moderationLogChannelId to preserve consistency in how we name them

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats right, this should be a channel ID. ++

services/spam-ban/spam-banning.service.js Outdated Show resolved Hide resolved
const embedMessage = new EmbedBuilder()
.setTitle("Banned: Compromised account / Spam")
.setDescription(
`Account is compromised and is used to spam phishing links.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`Account is compromised and is used to spam phishing links.
`Your account has been banned from The Odin Project Discord as it is compromised and is used to spam phishing links.

`Account is compromised and is used to spam phishing links.

If you would still like to continue using our server, make sure to change your password and recover your account.
After that send a detailed contact information to appeal the ban on theodinprojectcontact@gmail.com`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
After that send a detailed contact information to appeal the ban on theodinprojectcontact@gmail.com`,
After that send a ban appeal containing contact information to theodinprojectcontact@gmail.com`,

Additional: Not a team member, but it might be easier if the instructions also say to add something like [Ban Appeal] to the subject or send it to something like theodinprojectcontact+banappeals@gmail.com

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your input is valueable and always appreciated. We might also add a template for them to fill in the email too

channel.send({ embeds: [embed] });
}

static #isAdmin(member) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: it might be worth (probably in a follow up) to refactor check if a user is admin logic to a separate file; I think this is either the third or fourth occurrence of basically this exact code snippet

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is duplicated in may other services. This is what im indicating in my PR message. Many of those including tests should be moved to utils. But not sure if we are doing it in this PR or an upcoming one, wanted to see what maintainers think.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has now happened in #567

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for letting me know, I will integrate it

@Mclilzee
Copy link
Contributor Author

@TheOdinProject/moderators I would like the mod team to weigh on this. What the message to the user would be like, what kind of template. And perhaps some kind of a form so that they can use for the appeal?

This is the current template of the message

Account is compromised and is used to spam phishing links.

If you would still like to continue using our server, make sure to change your password and recover your account.
After that send a detailed contact information to appeal the ban on theodinprojectcontact@gmail.com

I would like to especially hear from @JustWaveThings since this was originally your idea, is this how you imagined it to be, or do you think it needs some improvements?

@JustWaveThings
Copy link
Contributor

I'll be happy to put together a message to send on the ban. I will look at the functionality of it tonight. Thank you so much for doing this!

@JustWaveThings
Copy link
Contributor

JustWaveThings commented Jul 13, 2024

@Mclilzee, Here's my take on the message the bot could send:

This account has been banned from The Odin Project Discord server for sending spam. If this account is compromised, please follow the steps linked in this Discord support article to secure your account.

Once your account is secure, you may appeal your ban by emailing theodinprojectcontact@gmail.com with your Discord username and that you are appealing your ban due to a compromised account.

Note: It may take several days for our volunteer staff to take action on your appeal, and unbanning is not guaranteed.

I don't know if we need to get fancy with the message. I'm also fine with just sending what we send now in the ban message.

@Mclilzee
Copy link
Contributor Author

@Mclilzee, Here's my take on the message the bot could send:

This account has been banned from The Odin Project Discord server for sending spam. If this account is compromised, please follow the steps linked in this Discord support article to secure your account.

Once your account is secure, you may appeal your ban by emailing theodinprojectcontact@gmail.com with your Discord username and that you are appealing your ban due to a compromised account.

Note: It may take several days for our volunteer staff to take action on your appeal, and unbanning is not guaranteed.

I don't know if we need to get fancy with the message. I'm also fine with just sending what we send now in the ban message.

This looks great! Thank you, Fred. This is much better than whatever I can cook with my broken English.

@Asartea
Copy link
Contributor

Asartea commented Jul 13, 2024

Very minor nit, but I think that the starting This should also be an Your, otherwise you're switching between modes of address

Copy link
Contributor

@MaoShizhong MaoShizhong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a quick few nits on grammar/spelling etc.

services/spam-ban/spam-banning.service.js Outdated Show resolved Hide resolved
services/spam-ban/spam-banning.service.js Outdated Show resolved Hide resolved
services/spam-ban/spam-banning.service.js Outdated Show resolved Hide resolved
services/spam-ban/spam-banning.service.test.js Outdated Show resolved Hide resolved
new-era-commands/context-menu/bann-spammer.js Outdated Show resolved Hide resolved
services/spam-ban/spam-banning.service.js Outdated Show resolved Hide resolved
Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>
Copy link
Contributor

@Asartea Asartea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, single n in file name ban-spammer.js.

I probably won't have a great deal of time to do a thorough review of the feature itself, I'm more doing little bits here and there, so I'll be cheeky and leave the rump of the stuff to Xari.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

spam ban app menu command: add right-click App context menu command for spam
5 participants