Giter Site home page Giter Site logo

codesupport / discord-bot Goto Github PK

View Code? Open in Web Editor NEW
21.0 21.0 21.0 2.3 MB

The CodeSupport Discord Bot

Home Page: https://codesupport.dev/discord

License: MIT License

TypeScript 99.53% JavaScript 0.41% Dockerfile 0.06%
bot discord discordjs hacktoberfest

discord-bot's People

Contributors

adam-devel avatar ajsaraujo avatar bananacrazy avatar bas-sarrechia avatar blackbearftw avatar chrisch7 avatar codacy-badger avatar dependabot[bot] avatar hexathe6 avatar hoffi-coffi avatar itsviolet avatar jacobgasser avatar jason2605 avatar jonavdm avatar kaelonr avatar lambocreeper avatar ndelta0 avatar olivier-b-be avatar pathway27 avatar salint avatar saramaebee avatar theboxmage avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

discord-bot's Issues

Add a commands command

It's not clear for newcomers how the bot is used - right now, the learning curve consists basically in watching other people use it. It would be nice if we had a ?commands command that shows what are the available commands and what each one of them does.

The command should loop over all the commands, getting their names, descriptions and aliases (if there are any) and finally showing this data on an embed.

A help alias would also fit nicely.

Embed Colours

We should take advantage of the ability to colourise embeds depending on their status:

  • Successes should be green (#35BC31)
  • Errors should be red (#BC3131)
  • Anything else should be the CodeSupport Blue (#1555B7)

These should be stored in the config.json as:

{
    "EMBED_COLOURS": {
        "SUCCESS": "#35BC31",
        "ERROR": "#BC3131",
        "DEFAULT": "#1555B7"
    }
}

Tests should also check the right embed colour is being sent if an embed and tested. Do not compare the value to the one in the config - these are not integration tests!

GitHub Issues Command

Usage: ?issues <username>/<repository>

As a: user
I want to: get a list of issues for a specific repository
So that I: can see them in Discord

This will require updating the GitHubService so that it has a new method, getIssues(), which returns an array of GitHubIssues (this will require a new interface).

When executing the command, an embed should be sent with the 3 most recent issues:
Example Embed

Remove Twitter Implementation

The bot still has code and NPM packages relating to the Twitter functionality which we used to have. This can all now be removed.

Bypass Ghostping for moderator deletes

When a moderator deletes a message, no ghost ping message should be generated. Currently when a moderator removes a message, the ghost ping will trigger. Messages deleted by a mod generally get deleted with reason.

Message Logs

As a: Moderator
I want to: see message logs
So that: I can see if anything suspicious is being said

When a message is edited, it should be logged to the #logs channel (ID: 405068878151024640) with the previous content, new content and author:
message-updated
This should be done inLogMessageUpdateHandler.

When a message is deleted, logged to the #logs channel (ID: 405068878151024640) with the previous content and author. This should be done inLogMessageDeleteHandler.

Add a development script

To run the bot in development we first have to transpile to JavaScript. It would be nice if we had a dev script that used ts-node to transpile and run on the fly, such as "dev": "ts-node src/app.ts".

Necessity of detecting ghost pinging bots

Currently, ghost pinging by deleting a message mentioning a bot (only bot or author + bot) is detected.
Deleting a reply (ping = on) to a bot is detected as well.

Is that the intended behavior? If not, I'd like to fix it.

Log Messages Which Are Bulked Deleted

As a moderator
I want to be able to see messages which are deleted in bulk
So that I can see what the Anti Spam Bot deleted


Event Trigger: messageDeleteBulk

For each message returned in the collection, an embed should be sent to the logs channel. This logic should be very similar the messageDelete logic.

Member Leave Embed

When guildMemberRemove is triggered, an embed should be sent in the channel LOG_CHANNEL_ID that sends an embed stating:

  • How long the member was in the guild (years, days, hours, minutes and seconds)
  • If the user was authenticated (they will have the role MEMBER_ROLE if so)

I am not sure if you can get the roles a user had from the quit event, so may need some investigation.

Hiring-and-looking custom cooldown against spam posts

What Functionality Are You Suggesting?

Please describe the functionality below:
Add a handler that allows users to only post in hiring-and-looking every x amount of days.

Why Will This Benefit The Community?

Please explain why this functionality would benefit our community below:
This will stop spam posts and it will also make life easier for the moderators.

Screenshot_20210729-223037.jpg

Open #hiring-or-looking only after user uses ?hl

Suggestion

Create a new role called "literate" (or anything you like) that will be given to users once they use the command ?hl. The only people able to send messages in #hiring-or-looking would be those with the "literate" role.

A custom pinning system.

Since Discord has a limit of 50 pins per channel. I thought about making a custom pinning system where you'd be able to pin a message using it's ID, and a command to take a look at the pins, maybe giving the message link to "jump" to the message.

Member Inspect Command

As a moderator
I want to be able to easily gather information about a user
So that I can fill out the member report form quicker


Command Usage: ?inspect <username | discord id>
Executeable by: Everyone
Executeable in: #bot-chat

Returns an embed with the following fields:

  • ID
  • Username + Discriminator (formatted as Username#Discriminator)
  • Joined Date + Time
  • Nickname
  • Roles

The embed colour should match the colour of their most senior role to be consistent with the quote embed.

Support V13

What Functionality Are You Suggesting?

Please describe the functionality below:
This PR will fix the changes described on here

this will not include the slash commands, buttons or select menu's

Why Will This Benefit The Community?

Please explain why this functionality would benefit our community below:
This will keep the bot up to date with the changes made to the discord api and discord.js library

Advertisement blocker

What Functionality Are You Suggesting?

Please describe the functionality below:

Feature to detect and respond to a limited scope of suspected advertisements.

  • Feature will be limited to members who have joined within X (configurable) hours with the Member role.
    • Messages will be tracked in-memory only.
    • Tracked user messages will be erased after user has stayed for longer than X (configurable) hours.
  • Feature will kick users who post the same message in N (configurable) channels.
  • Feature will delete only the messages from the user that triggered the advertisement detection.

Why Will This Benefit The Community?

Please explain why this functionality would benefit our community below:

There have been an increase in nitro advertisements being spammed in multiple channels. This feature will allow these messages to be quickly cleaned up and dealt with when moderators are not available, allowing them to add additional bans manually at a later point via the logged messages.

GitHub Command

This should be similar to the SearchCommand and InstantAnswerService.

GitHubService

Create a GitHubService singleton (just base it on any of the other services) with method getRepository(user: string, repo: string) that calls https://api.github.com/repos/<user>/<repository>.

GitHubCommand

Command Usage: ?github <username>/<repository>

If a parameter is not supplied, return an error stating the correct usage (similar to the ?npm command). If a parameter is supplied, perform a GET request: if 200 is returned send an embed with the repository information as the repository is valid, if not state that a repository of the supplied name could not be found.

The embed should contain:

  • The repository name and who it's by in the title
  • The description of the repository
  • The primary language of the repository
  • The number of open issues
  • The number of open pull requests
  • A button to view the repository on GitHub

We could also add the number of forks and stars, but it might make the embed quite large.

Resources Command

A command to help users share the resources we recommend on the website.

Usage: ?resources <category>

The bot should then output https://codesupport.dev/resources?category=<category>. Simple as that!

I suggest adding resource as an alias for better usability.

Persistent Muting

Currently, when a user leaves the server with the muted role the muted role goes with them. They are able to rejoin and wreak havoc once again (like i did).

There should be a way so that the mute persists through kicking or the muted user leaving and rejoining.

"codeblocks" doesn't trigger the codeblock command

Sometimes you want to trigger the codeblock command, so you enter codeblocks. Nothing happens. Then you try codeblock and it works. It would be nice if both codeblock and codeblocks triggered this command.

NPM Command

Get a link to an NPM package.

Command Usage: ?npm <package>

If a package is not supplied, return an error stating the correct usage (similar to the ?rule command). If a package is supplied, perform a GET request: if 200 is returned send the link as the package is valid, if not state that a package of the supplied name could not be found.

This command should function identically to the one in the old Discord bot (see here).

A new feature which uses sandboxed API for executing user code on-the-fly

What Functionality Are You Suggesting?

Please describe the functionality below:
It will be a feature that will enable users to run code from many different languages in Discord itself, under a sandboxed API environment.

Why Will This Benefit The Community?

Please explain why this functionality would benefit our community below:
This feature will greatly help helpers as they would be able to run the problematic code and see the error or output in detail on the fly without opening a compiler. If output is long or it is an error it will be dmed so they can fix it efficiently. Very beneficial for small problems.

caniuse Search

Creating an issue at the man's request:
image

A few months back, Lambo thought it was a good idea for a quick search to produce an embed for the relevant caniuse.com output, but it got forgotten about. This is just here as a reminder in case he finds the time or somebody else feels like chipping in (maybe I might try to get my act together).

Roleinfo command.

Would a command that gives you more information about a role be handy, for contributor and verified role (and others)?

Screenshot_20210322-134547.jpg

Verfied - bypass filter file upload.

verified members should be allowed to bypass the file upload filter. This is due to that verified members handle this more responsible over the average user.

Hashtags in Tweets come through as URLs in the embed.

If a Tweet contains a hashtag it currently comes through as a URL. Clicking on these URLs does not even take you to the right hashtag, so I'm not totally sure what's causing it. Anyway, we should just have the raw hashtags in the embed - I'm not too bothered about them being clickable.

Also, the tweet embed needs to be updated so that it has the default embed colour.

”Missing Access” when not running in production.

When you run the bot locally it produces a DiscordAPIError stating that it has ”Missing Access”. This is due to it not being able to cache the authentication channel and message. We need to add a check so that this only happens when the NODE_ENV is production.

bug/RaidDetection slow down warning messages

Overview

Please describe the bug below:
Currently the bot spams general full with warnings, I have a solution for this problem, by adding in a queue_counter that only sends the message every x amount of dealt with queues

Expected Behaviour

Please describe how you expect this functionality to work:
It should slow down and not send that message as often

Actual Behaviour

Please describe how this functionality is actually working:
As I said, general now gets spammed multiple times back to back.

Enforce Codeblocks Over File Uploads

As a: Member
I want to: Be told to use a codeblock over a file upload
So that: People do not have to download my code

@AtrumAmantus suggested to me that it would be a good idea to detect file uploads and tell users to send their code as codeblock rather than a file upload.

I think the simplest way to do this would be by just allowing uploads of:

  • .jpg
  • .jpeg
  • .png
  • .gif
  • .mp4

If we detect they are uploading a file which does not match one of those extensions the bot should say:

@UserWhoUploadedTheFile Please use codeblocks over uploading code files. Type ?codeblock for more information.

The supported file extensions should be stored in the config.json as an array of strings called SUPPORTED_FILE_UPLOADS.

This should be done in CodeblocksOverFileUploadsHandler.

Re-implement Twitter Service

We removed the Twitter service temporarily in #85 to fix a bug where the bot crashed on deployment.

We need this feature added back, but obviously do not want it to crash the bot.

Use npm ci in CI jobs

Currently we're using npm i to install dependencies on the CI automated tasks. We should be using npm ci instead.

StackOverflow Thread

Files to change:

  • .github/workflows/main.yml
  • .github/workflows/coverage.yml

Don't Post Retweets

Currently, when someone retweets any tweet made by us it sends it in general with the prefix ”RT”.

This shouldn't happen as it gets quite spammy.

Although, it should still post any tweets that we retweet.

Ghostping reply doesn't show original message author

Problem: Currently the bot does detect when a reply was deleted that pinged the original message author, but the embed doesn't show that pinged user. Which would be useful information.

reply

Solution: Add an if statement to check if the message was a reply, then add an extra field to the embed, that would look like:
Replied To:
@mention

Optional: Also show the content of the message that was replied to.

! Not working mid-sentence to ignore message reference

Currently an embed will still be generated if the message doesn't start with ! + Message link

Bug fix has to make it so ! Can be used anywhere in the message.

Also changing ! To <> to keep bot symbols consistent with discord.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.