Git Product home page Git Product logo

modmail's Introduction

drawing

ModMail

Maintenance GitHub package.json version GitHub repo size GitHub package.json dependency version (prod) Discord Support

1. Features

  • Per user ticket channels
  • Leave notes for other staff members in ticket channels (not visible by ticket users)
  • Set status messages for tickets
  • Assign tickets directly to staff members
  • Block users from using ModMail
  • Status/HUD channel to view all open tickets
  • Separate the hud channel into a backend/admin only server
  • Easily close tickets by deleting ticket channels with Discord or use the built in command
  • Log ticket contents after the ticket is closed for security and safety

2. Commands

Where [p] is prefix

alldata: Dump all data to console
Usage: [p]alldata 

block: Block and unblock a user from using ModMail.
Usage: [p]block [@mention] 

delete: Remove ticket by user ID in database.
Usage: [p]delete 

help: This message!
Usage: [p]help 

ping: See bot response time. Ping!
Usage: [p]ping 

3. Ticket Channel Commands

Where [p] is prefix

close: Close the ticket with an attached reason, this method sends a message to the user notifying them their ticket has been closed.
Usage: [p]close [reason string]

note: Leave a little message/note in the ticket channel for other staff members to see
Usage: [p]note [note string]
You can also prefix a message in the ticket channel with # to send a note (Example: "# Hello world")

status: Update ticket status message to quickly view the progress of a ticket
Usage: [p]status [new status string]

data: Sends all ticket data stored in DB into the ticket channel
Usage: [p]data

assign: Assign a ticket to a specific staff member and DM notify them of the ticket
Usage: [p]assign [@mention]

4. Requirements

  • Tested on Node.JS v16.6.0 (npm 7.19.1)
  • Made and tested with DiscordJS v13.6
  • File system access is required
  • Git

5. Config Files Setup

Setting up settings.json

  • Fill in all the following fields, currently commands to edit these fields do not exist. Restarting should not be required if you edit any of these files whilst the bot is running.
  • All channels are IDs and NOT channel names
  • Do not edit the lock or blockedUsers value.
  • readAccess and writeAccess will only be set once the Category is FIRST created, if you want to edit the permissions of the category use the "Edit Channel" feature built into Discord.
  • If you plan to send logs to ONE guild leave logtoStaff as false, if you are going to use the second guild, set logtoStaff to true.
{
  "prefix": "$", //Utility prefix
  "lock": false,
  "primaryGuild": { //This is the server that will accept DMS from users
    "id": "", 
    "logChannel": "", //Log ticket activity here
    "categoryID": "" //The ID of the category to put ModMail tickets, automatically created on startup if it does not exist.
  },
  "staffGuild": { //Your backend guild (optional), leave blank if not using
    "id": "", 
    "logChannel": "", //Log ticket activity here
    "hudChannel": "" //The chanel ID to use as the HUD
  },
  "logToStaff": false,
  "readAccess": [""], //Give roles or users access to read messages (use IDS)
  "writeAccess": [""], //Give roles or users access to read and send messages (use IDS)
  "blockedUsers": [""],
  "messages": {
    "ticketCreated": "We have created a new ticket for you! We will get back to regarding your inquiry as soon as possible.",
    "ticketClosed": "Your ticket has been closed! Thank you for reaching out to us and have a good day.",
    "blocked": "You have been blocked from direct messaging ModMail.",
    "locked": "ModMail is currently locked from accepting direct messages."
  }
}

.env File Setup

  • Token is your Discord bot developer token
  • Set DB_USER and DB_PASSWORD to something secure and keep it safe.
TOKEN=
DB_USER=
DB_PASSWORD=

6. Installation

  1. Clone the repository git clone https://github.com/Saamstep/modmail.git
  2. Change your working directory cd modmail/
  3. Install NPM modules npm install --save
  4. Copy the example config file and edit it accordingly cp example.config.json config.json
  5. Copy the example env file and edit it accordingly cp example.env .env
  6. Run the bot with node . OR use pm2 to keep it alive (See PM2 section)
  7. Invite your bot using my Invite Generator. You need your client ID which is found in your Developer Portal

7. Examples

Status/HUD Channel

hud channel example image

Notes

note example

modmail's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar saamstep avatar

Stargazers

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

Watchers

 avatar

modmail's Issues

Missing script

Describe the bug
Missing the start script
To Reproduce
Steps to reproduce the behavior:

  1. Start bot

Expected behavior
I started the bot and it is saying it's missing teh start script

Console/Error logs
îș§ npm start
npm ERR! missing script: start

npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2021-03-02T13_59_24_018Z-debug.log

System Info

repl.it
12.16.1
6.14.6
discord.js-commando version 0.12.2
2
missing script: start
Additional context
Add any other context about the problem here.

[BUG] - Short desc

C:\Users\Saksham\Desktop\New folder\node_modules\discord.js\src\rest\RequestHandler.js:154
throw new DiscordAPIError(request.path, data, request.method, res.status);
^

DiscordAPIError: Invalid Form Body
embed.footer.icon_url: Scheme "null" is not supported. Scheme must be one of ('http', 'https').
embeds[0].footer.icon_url: Scheme "null" is not supported.

I'm getting this error while running the code i guess you should upgrade discord.js module as v12 is no longer supported

Error

(node:2356) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'channels' of undefined
    at hasCategory (C:\Users\olebo\OneDrive\Dokumente\GitHub\FormelS\discord\index.js:766:13)
    at CommandoClient.<anonymous> (C:\Users\olebo\OneDrive\Dokumente\GitHub\FormelS\discord\index.js:907:9)
    at CommandoClient.emit (events.js:327:22)
    at MessageCreateAction.handle (C:\Users\olebo\OneDrive\Dokumente\GitHub\FormelS\discord\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (C:\Users\olebo\OneDrive\Dokumente\GitHub\FormelS\discord\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (C:\Users\olebo\OneDrive\Dokumente\GitHub\FormelS\discord\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
    at WebSocketShard.onPacket (C:\Users\olebo\OneDrive\Dokumente\GitHub\FormelS\discord\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (C:\Users\olebo\OneDrive\Dokumente\GitHub\FormelS\discord\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
    at WebSocket.onMessage (C:\Users\olebo\OneDrive\Dokumente\GitHub\FormelS\discord\node_modules\ws\lib\event-target.js:132:16)
    at WebSocket.emit (events.js:315:20)
This error is spammed in the console
It's about this line:
  // check if guild modmail category exists
function hasCategory(g) {
 if (g.channels.cache.find((ch) => ch.id == client.config.modmail.category || ch.name == client.config.modmail.category)) {
   return true;
 } else {
   return false;
 }
}

Replit Issue

While the console is almost done installing packages, it keep saying replit package operation failed.

[READ ME] Before submitting an issue

What goes in Github Issues

  • Bug reports
  • Suggestions
  • Documentation clarifications

What does not go in a Github Issue

  • Asking for help with any errors or bot functions
  • Asking questions that can be answered or found in the readme.md
  • Anything unrelated to the Modmail project

Issues

If you are having an issue you have come to the right place! Please be as specific as possible include the following with your issue:

Operating System/Host info
NodeJS version
NPM version
DiscordJS version
Bot version (found with [p]bot command where [p] means prefix)
Any errors/log output that appeared in the console

Simply saying "it is not working" is not helpful to me. Please make sure you provide the information above!

Click Here to create your first issue

Suggestions

If you have a suggestion please be as descriptive and as possible when making a suggestion. If you have feedback constructive feedback is very helpful and taken!
Click here to send feedback or make a suggestion

Help wanted

When I use repl, since I'm not going to host myself until I'm sure it works, when I hit start I get this.
image

Import the repo to repl, press start.

For it to not send this error and work.

Already at the top.

most ticket commands are not working

well i noticed that the snippets command is working but noone can use the created snippets as we tried many time by snippet with/without prefix with all possible syntaxes but not working (of course both in ticket and non-ticket channels) , also the close and cmds commands are the same but others looks ok

also no console error at all, seems that commands are not defined at all

replit
Node JS v12.22.6
NPM v6.14.15
discord.js v12.5.2
bot v2.1.2
no error

what should i do? is it a bug or i missed something?

Fixed `announce.js` command...

There was a bit of trouble with Modmail announce.js code so here's my spin on it to help with the issue:

const { Command } = require("discord.js-commando");

module.exports = class announceCommand extends Command {
  constructor(client) {
    super(client, {
      name: "announce",
      group: "admins",
      memberName: "announce", 
      throttling: {
          usages: 2,
          duration: 5,
			},
      description: "Make a formatted announcement using embed data", 
      args: [
        {
          key: "option",
          prompt: "Please choose a valid option \`edit, append, embed\`",
          type: "string",
          oneOf: ["edit", "append", "embed"],
        },
        {
          key: "id",
          prompt: "Please provide a message id to edit or mention a channel to send this message to",
          type: "string",
          validate: (id) => {
            if(id.match(/^[0-9]*$/)) {
              return true;
            } else {
                return "Please enter a proper snowflake!"
            }
          }
        },
        {
          key: "title",
          prompt: "Please provide some title text.",
          type: "string",
          validate: (title) => {
            if (title.length < 256) {
              return true;
            } else {
                return "Please enter embed title under 256 characters!"
            }
          }
        },

        {
          key: "body",
          prompt: "Please provide some body text.",
          type: "string",
          validate: (body) => {
            if (body.length < 2048) {
              return true;
            } else {
                return "Please enter embed description under 2048 characters!";
            }
          }
        },
        {
          key: "color",
          prompt: "Please provide some color.",
          type: "string",
        },
        {
          key: "image",
          prompt: "Please provide an image URL.",
          type: "string",
          validate: (image) => {
            if (image.match(/([a-z\-_0-9\/\:\.]*\.(jpg|jpeg|png|gif))/i)) {
              return true;
            } else {
                return "Please enter a proper image URL with the listed extensions!";
            }
          }
        },
        {
          key: "footer",
          prompt: "Please provide some footer text.",
          type: "string",
          validate: (footer) => {
            if (footer.length < 2048) {
              return true;
            } else {
                return "Please enter embed footer under 2048 characters!";
            }
          }
        },
 
      ],
    });
  }

  async run(message, { option, id, title, body, color, image, footer }) {
    switch (option) {
      case "edit":
        try {
          message.channel.messages.fetch(id).then((m) => {
            m.edit({
              embed: {
		title: title,
                description: body,
		color: color,
		footer: footer,
		image: image
              },
            });
          });
        } catch (e) {
          return this.client.error(e + "Channel not found, you must run in same channel as message!", message);
        }
        break;
      case "append":
        try {
          message.channel.messages.fetch(id).then((m) => {
            m.edit({
              embed: {
                description: m.embeds[0].description + " " + body,
              },
            });
          });
        } catch (e) {
          return this.client.error("Channel not found, you must run in same channel as message!", message);
        }
        break; 
      case "embed":
        try {
          let announceChannel = this.client.channels.cache.get(`${id.replace(/</g, "").replace(/>/g, "").replace(/#/g, "")}`);
          announceChannel.send({ embed: { title: title, description: body, image: { url: image }, footer: { text: footer }, color: color } });
        } catch (e) {
          return this.client.error(e, message);
        }
        break;    }
    message.delete();
  }
};

Let me know your thoughts boss :)

Suggestion

I would like:

  • We can choose the type of status (watch, listen ...)
  • We can choose the rotation time of the status (for my part, I would like 3 seconds)
  • The bot be adapted with Nodejs V12

Here is my opinion, I hope that some of these features will be present during the next update.

[BUG] - Issue with DM bot.

Describe the bug
Writes DM to BOT and this error appears in PuTTY.

To Reproduce
Steps to reproduce the behavior:

  1. Start the bot
  2. DM the bot and type: hi
  3. get an error about 'id'

Console/Error logs

(node:910395) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined
    at CommandoClient.<anonymous> (/home/marc/modmail/index.js:449:112)
    at CommandoClient.emit (events.js:387:35)
    at MessageCreateAction.handle (/home/marc/modmail/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (/home/marc/modmail/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (/home/marc/modmail/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
    at WebSocketShard.onPacket (/home/marc/modmail/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (/home/marc/modmail/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
    at WebSocket.onMessage (/home/marc/modmail/node_modules/ws/lib/event-target.js:132:16)
    at WebSocket.emit (events.js:375:28)
    at Receiver.receiverOnMessage (/home/marc/modmail/node_modules/ws/lib/websocket.js:970:20)

System Info

Operating System/Host info: Ubuntu 20.04
NodeJS version: 14.17.3
NPM version: 6.14.13
DiscordJS version: 12.5.3
Bot version: 2.1.2

Ignoring DMS

(node:236) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'channels' of undefined at hasCategory (/home/runner/modmail/index.js:283:9) at CommandoClient.<anonymous> (/home/runner/modmail/index.js:420:9) at CommandoClient.emit (events.js:327:22) at MessageCreateAction.handle (/home/runner/modmail/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14) at Object.module.exports [as MESSAGE_CREATE] (/home/runner/modmail/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32) at WebSocketManager.handlePacket (/home/runner/modmail/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31) at WebSocketShard.onPacket (/home/runner/modmail/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22) at WebSocketShard.onMessage (/home/runner/modmail/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10) at WebSocket.onMessage (/home/runner/modmail/node_modules/ws/lib/event-target.js:125:16) at WebSocket.emit (events.js:315:20) (node:236) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:236) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

[UPDATE] New Re-write coming soon

In light of DiscordJS v13 and seeing a lot of changes I want to make internally I am in the process of re-writing this bot. No exact update or timeline just yet, but be on the lookout for a huge update!

A Discord Help Support Server?

Hey there , I really loved the code , however would it be possible for you to make a Discord Support server for the code and we could reach out for help , also a Youtube video describing how to setup the bot will be highly appreciated. Thanks!

Idea

Suggestions:
Use comands:
!setcategory (ID)
!setlogchannel (ID)
!reply (Replies to a thread)
!close (time)
!snippets (In thread commands)
!move (Moves to a Category)
!suspend (Suspends a thread(
!unsuspend (Unsuspends a thread)
!block (Blocks a user from using modmail)

Console error

Hello, i can't start the bot because of this error

[Login] Error [DISALLOWED_INTENTS]: Privileged intent provided is not enabled or whitelisted.

I searched everything but i don't find anything.

Could you help me?

Is this v13?

Hey! I just wanted to ask, is this bot is v13 or v12? I cannot seem to make the bot function when its online.

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.