Giter Club home page Giter Club logo

ban_appeal_plugin's Introduction

Ban Appeal Server & Plugin

This repo contains two things, a webserver for ban appeals and a python cog/plugin for modmail which is here.

Setting up

To get started with it, first you need to have an active instance of both modmail and logviewer otherwise it won't work.

Docker

To host with docker:

  • I'll assume you have docker installed since you're following docker steps.
  • Git clone this repo with git clone https://github.com/DjDeveloperr/ban_appeal_plugin.
  • Go into the directory where you cloned it and open a terminal session inside the ban_appeal_plugin directory.
  • Then, build the docker image by running this command docker build . -t appeal-server --build-arg PORT=2012, replace PORT=2012 with whatever port you want the application to run on, it can only be set during build process.
  • Run cp .env.example .env if on linux/osx or copy .env.example .env for windows and fill the .env file with all the correct tokens and IDs .
  • After the image has been built, run it in a container with the command docker run -d -p PORT:PORT --env-file .env --restart unless-stopped appeal-server, the PORT has to be the same port you provided in the previous step while building the image. The command you run looks something like this docker run -d -p 2012:2012 --env-file .env --restart unless-stopped appeal-server.

Following the above steps properly will have a fully functioning appeal server running on a docker container.

Selfhost

To host in your machine:

  • Assuming you have deno installed, run cp .env.example .env if on linux/osx or copy .env.example .env for windows.
  • Fill the .env file with all the correct tokens and IDs.
  • Start the app by running deno run --no-check --allow-net --allow-read --allow-write --allow-env main.ts.

If you did everything correctly you should see Listening to ... in console which means it's running.

Adding the plugin and instructions to use it

[p] is your prefix. To get started with the plugin:

  • First add the plugin to your bot by running [p]plugins add DjDeveloperr/ban_appeal_plugin/ban_appeal@main.
  • You can configure the ban appeals category where channels will be made for appeals by running [p]banappeal category category_id, don't provide category_id to see the currently set category.
  • You can add a question for appeals by doing [p]banappeal questions add your question or you can add in bulk by doing [p]banappeal questions setlist "question1" "question2" questions with spaces must be wrapped in quotes "" like "this".
  • To remove a question [p]banappeal questions remove index-of-the-question, you can find the list of questions and see their indexes by running [p]banappeal questions list
  • [p]accept to accept an appeal and [p]deny to reject it.

Commands

There's a few commands in the plugin. [p] is your prefix.

  • [p]accept
  • [p]deny
  • [p]banappeal

Environmental Variables

You need to obtain few env variables for this.

  • MONGO - It's your mongodb URI which you use for your modmail instance and add /?authMechanism=SCRAM-SHA-1 to it if there's no query parameter already in the URI. It looks something like mongodb+srv://Username:[email protected]/?authMechanism=SCRAM-SHA-1 as I did have a query parameter already, I added &authMechanism=SCRAM-SHA-1.
  • PORT - The port on which the server will run on.
  • GUILD_ID - The modmail guild ID used in your modmail instance.
  • CLIENT_ID - The client ID of your modmail bot, it can be obtained here in the OAuth2 section.
  • CLIENT_SECRET - The client secret of your modmail bot, it can also be obtained in the OAuth2 section of your bot in discord.dev.
  • TOKEN - The token of your modmail bot, you can find it in the Bot section in discord.dev.
  • REDIRECT_URI - The domain/ip of your server where everyone can access your ban appeals server, if you use a domain you're on your own to setup a reverse proxy like nginx. Your domain/ip should also contain /discord with it like: http://localhost:6969/discord. Note you also have to add this in the Redirects section in the OAuth2 menu of your bot in discord.dev, otherwise it won't work.

License

Check here for more info.

ban_appeal_plugin's People

Contributors

6days9weeks avatar alarubra123 avatar djdeveloperr avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

gayncomfy

ban_appeal_plugin's Issues

Bot commands not embedded.

All the command responses are sent as normal message content, rather than embeds.

Ideally, they would respond as embeds with the configured error and ok colors for ModMail, as appropriate. This would be more consistent with the core bot.

Connecting to Mongo

To connect to the Atlas Mongo instance I set up following the ModMail wiki I needed to add &authMechanism=SCRAM-SHA-1 to my mongo connection string.

Probably a good idea to add that to the readme. Maybe in a "Troubleshooting" section.

Command permissions in help text.

None of the commands under the "banappeal" group show a permission level in the [p]help command, because they don't have one explicitly set with a decorator. They still respect the inherited permissions of the group, as expected, but ideally, like core ModMail, they'd all have decorators so the actual required permission level shows in the help command response.

Default questions.

If there are no questions set through the bot, there's a default set of questions that show on the site. But, when you do [p]banappeal questions list it shows "No questions have been set!" which would seem to indicate to me that no questions will show on the site. (Leading to the site either being non-functional or allowing users to submit an empty appeal)

This message should say something like:

No questions have been set. Default questions will be used:
1. Who banned you?
2. Why do you think you were banned?
3. Are you sorry?

License

When we discussed on Discord, I asked if you'd be willing to release under MIT, but I see the repo is under the the Apache 2.0 License.

Is there a particular reason for this change?

Use of `bot.api`

https://github.com/kyb3r/modmail/wiki/Plugins#database-interfacing
Says:

Do not interact with bot.api directly. Fetch a partition and use it:

Yet, in https://github.com/DjDeveloperr/ban_appeal_plugin/blob/main/ban_appeal/ban_appeal.py#L299 self.bot.api is directly called for the post_log method. Is this not possible to due through the partition?

Additionally, that's under the section "Database Interfacing", but I notice bot.db is being used directly? Are the interactions there not possible through a partition?

I'm not very experienced with Python, nor have I done a deep dive of Modmail's codebase, so if there's something I'm missing here, just let me know.

Previous appeal accepted.

On the "Can't re-appeal." error page, for an accepted appeal, it would be nice to add some additional context.

So, instead of this:
"Your previous appeal was accepted."

This:
"Your previous appeal was accepted.
You have since been banned again, and are ineligible to re-appeal."

(I know this contradicts what I said during initial discussion a bit, but I've thought it through a bit more since.)

docker run command.

Docker run supports .env with the --env-file parameter, so you can fill out the .env file, and pass that rather than using the -e parameter for each environment variable. Also, the -p parameter is needed to expose the port to the web/nginx, and it's probably best to run detached with a restart policy.

So, I think the docker run command should look more like docker run -d -p 2012:2012 --env-file .env --restart unless-stopped appeal-server with instructions to fill out the .env file before running.

At least that's how I launched mine, and what I needed to do to get it running as I wanted.

Bot can create a ban appeal thread it can't view/send messages in

Core ModMail, when creating a new thread, creates with the default permissions for the category, (d.py standard) then adds a user specific override to allow the bot too see the channel, in case it's not already included in the category permissions. This ensures that threads are more likely to work as intended.

It would be ideal to do the same for ban appeal threads, to help prevent any permissions issues.

Character limit

It's possible to fill out an appeal and hit the character limit for an embed/message in Discord with just 6 questions (which isn't an unreasonable amount for an appeal form)

In this case, the bot opens an appeal thread, but the message fails to send in the channel and questions/answers don't show in the logs.

This is something that's unlikely to be a problem in a real appeal, as people won't realistically be intentionally maxing out the character limit, so feel free to mark as "wont fix" if resolving this is too much of a hassle. But, it'd be nice to support this edge case if possible.

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.