Cyanic76 / discord-modmail

THIS IS A MIRROR. ISSUES AND PR MUST BE SUBMITTED TO CODEBERG.
https://codeberg.org/Cyanic76/discord-modmail
MIT License
77 stars 48 forks source link

dbTable & text not defined #26

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hello the only thing that works is creating channel. The bot dont send user message, any command dont work (dbTable not found), if you dm multiple times it just keep create new ticket

ghost commented 3 years ago

![Uploading 1624991487758..jpg…]() (doesn't work)

ghost commented 3 years ago

I get this when i DM bot

ghost commented 3 years ago

Also permissions broken

Cyanic76 commented 3 years ago

I can't help you: your pic is broken. If you're not using repl.it, delete the replit.js file.

Cyanic76 commented 3 years ago

Also did you set correct role IDs?

ghost commented 3 years ago

Yes, everything correct. And i deleted that file

Cyanic76 commented 3 years ago

This pic is broken

ghost commented 3 years ago

Do you have discord? Will be easier for me

Another19-archived commented 3 years ago

ReferenceError: dbTable is not defined at Client. (/root/modmail/bot.js:110:17) at Client.emit (events.js:388:22) at MessageCreateAction.handle (/root/modmail/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14) at Object.module.exports [as MESSAGE_CREATE] (/root/modmail/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32) at WebSocketManager.handlePacket (/root/modmail/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31) at WebSocketShard.onPacket (/root/modmail/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22) at WebSocketShard.onMessage (/root/modmail/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10) at WebSocket.onMessage (/root/modmail/node_modules/ws/lib/event-target.js:132:16) at WebSocket.emit (events.js:376:20) at Receiver.receiverOnMessage (/root/modmail/node_modules/ws/lib/websocket.js:845:20)

this error shows every time when user sent a message on a channel that is NOT a support channel

Edited: well technically, this issue can be fixed by moving the `const dbTable = new db.table("Tickets"); to something like this:

 client.on('message', async message => {
    const dbTable = new db.table('Tickets');
Cyanic76 commented 3 years ago

Well, move the const to the top of the client.on function like you did

ghost commented 3 years ago

Okay i will try.

ghost commented 3 years ago

But i also have

ReferenceError: text is not defined

Cyanic76 commented 3 years ago

What line?

Another19-archived commented 3 years ago
Line 94 -  client.channels.cache.get(active.channelID).send(`${message.author.username} > ${text}`, {files: [message.attachments.first().url]})
Line 96 -  if(e) client.guilds.cache.get(config.guild).channels.cache.get(active.channelID).send(`${message.author.username} > ${text}`, {files: [message.attachments.first().url]})
Line 100 - client.channels.cache.get(active.channelID).send(`${message.author.username} > ${text}`);
Line 102 - if(e) client.guilds.cache.get(config.guild).channels.cache.get(active.channelID).send(`${message.author.username} > ${text}`)

You didn't define text to anything, and therefore it's returning undefined. And also, you defined msg to message content. Line 84 - var msg = message.content; But it was never used. Maybe by changing ${text} to ${msg}?

Cyanic76 commented 3 years ago

Should be fixed now.

DmanAwesome1 commented 3 years ago

Hey so this isnt working too great. It doesnt start for me, even if I put everything in pls help

DmanAwesome1 commented 3 years ago

Error: Cannot find module './config.json' Require stack:

Error: ENOENT: no such file or directory, open '/home/runner/AE-Modmail/index.js' at Object.openSync (fs.js:462:3) at Object.readFileSync (fs.js:364:35) at Object. (/run_dir/interp.js:195:19) at Module._compile (internal/modules/cjs/loader.js:999:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) at Module.load (internal/modules/cjs/loader.js:863:32) at Function.Module._load (internal/modules/cjs/loader.js:708:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) internal/fs/utils.js:269 throw err; ^

Error: ENOENT: no such file or directory, open '/home/runner/AE-Modmail/index.js' at Object.openSync (fs.js:462:3) at Object.readFileSync (fs.js:364:35) at Object. (/run_dir/interp.js:195:19) at Module._compile (internal/modules/cjs/loader.js:999:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) at Module.load (internal/modules/cjs/loader.js:863:32) at Function.Module._load (internal/modules/cjs/loader.js:708:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) at internal/main/run_main_module.js:17:47 { errno: -2, syscall: 'open', code: 'ENOENT', path: '/home/runner/AE-Modmail/index.js' } 

Cyanic76 commented 3 years ago

Are you using replit?

Download the index.js and config.json files again

DmanAwesome1 commented 3 years ago

I am using replit. When I download all the files again it starts the process then dies immediately.

DmanAwesome1 commented 3 years ago

And I did everything that you told replit users to do. What files do I need to remove exactly?

DmanAwesome1 commented 3 years ago

What is your discord because the one on your website doesnt work

Cyanic76 commented 3 years ago

What files do I need to remove exactly?

You have to remove the index.js. Then, replace index.js by replit.js in the package.json at lines 5 and 7.

What is your discord

this

DmanAwesome1 commented 3 years ago

node v12.16.1 

Replit: Updating package configuration

--> npm init -y Wrote to /home/runner/AE-Modmail/package.json:


{
  "name": "AE-Modmail",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "dependencies": {
    "chalk": "^4.1.1",
    "cors": "^2.8.5",
    "discord.js": "^12.5.3",
    "discord.js-commando": "^0.12.3",
    "express": "^4.17.1",
    "helmet": "^4.6.0",
Server {
  insecureHTTPParser: undefined,
  _events: [Object: null prototype] {
    request: [Function: app] EventEmitter {
      _events: [Object: null prototype],
      _eventsCount: 1,
      _maxListeners: undefined,
      setMaxListeners: [Function: setMaxListeners],
      getMaxListeners: [Function: getMaxListeners],
      emit: [Function],
      addListener: [Function: addListener],
      on: [Function: addListener],
      prependListener: [Function: prependListener],
      once: [Function: once],
      prependOnceListener: [Function: prependOnceListener],
      removeListener: [Function: removeListener],
      off: [Function: removeListener],
      removeAllListeners: [Function: removeAllListeners],
      listeners: [Function: listeners],
      rawListeners: [Function: rawListeners],
      listenerCount: [Function: listenerCount],
      eventNames: [Function: eventNames],
      init: [Function: init],
      defaultConfiguration: [Function: defaultConfiguration],
      lazyrouter: [Function: lazyrouter],
      handle: [Function: handle],
      use: [Function: use],
      route: [Function: route],
      engine: [Function: engine],
      param: [Function: param],
      set: [Function: set],
      path: [Function: path],
      enabled: [Function: enabled],
      disabled: [Function: disabled],
      enable: [Function: enable],
      disable: [Function: disable],
      acl: [Function],
      bind: [Function],
      checkout: [Function],
      connect: [Function],
      copy: [Function],
      delete: [Function],
      get: [Function],
      head: [Function],
      link: [Function],
      lock: [Function],
      'm-search': [Function],
      merge: [Function],
      mkactivity: [Function],
      mkcalendar: [Function],
      mkcol: [Function],
      move: [Function],
      notify: [Function],
      options: [Function],
      patch: [Function],
      post: [Function],
      pri: [Function],
      propfind: [Function],
      proppatch: [Function],
      purge: [Function],
      put: [Function],
      rebind: [Function],
      report: [Function],
      search: [Function],
      source: [Function],
      subscribe: [Function],
      trace: [Function],
      unbind: [Function],
      unlink: [Function],
      unlock: [Function],
      unsubscribe: [Function],
      all: [Function: all],
      del: [Function],
      render: [Function: render],
      listen: [Function: listen],
      request: [IncomingMessage],
      response: [ServerResponse],
      cache: {},
      engines: {},
      settings: [Object],
      locals: [Object: null prototype],
      mountpath: '/',
      _router: [Function]
    },
    connection: [Function: connectionListener],
    listening: [Function: bound onceWrapper] { listener: [Function] }
  },
  _eventsCount: 3,
  _maxListeners: undefined,
  _connections: 0,
  _handle: TCP {
    reading: false,
    onconnection: [Function: onconnection],
    [Symbol(owner_symbol)]: [Circular]
  },
  _usingWorkers: false,
  _workers: [],
  _unref: false,
  allowHalfOpen: true,
  pauseOnConnect: false,
  httpAllowHalfOpen: false,
Hint: hit control+c anytime to enter REPL.
 

Replit: Updating package configuration

--> npm init -y
Wrote to /home/runner/AE-Modmail/package.json:

{
  "name": "AE-Modmail",
internal/fs/utils.js:269
    throw err;
    ^

Error: ENOENT: no such file or directory, open '/home/runner/AE-Modmail/index.js'
    at Object.openSync (fs.js:462:3)
    at Object.readFileSync (fs.js:364:35)
    at Object.<anonymous> (/run_dir/interp.js:195:19)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47 {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/home/runner/AE-Modmail/index.js'
}```

this is the error I get when I run it
Cyanic76 commented 3 years ago

replace this "main": "index.js", with this "main": "replit.js",

DmanAwesome1 commented 3 years ago

replace this "main": "index.js", with this "main": "replit.js",

Yeah I did that.

Cyanic76 commented 3 years ago

What's the output?

DmanAwesome1 commented 3 years ago
Screen Shot 2021-07-07 at 10 27 46 AM

these are my files

Cyanic76 commented 3 years ago

I'll ask you to cancel these changes and rename replit.js to index.js file.

DmanAwesome1 commented 3 years ago

I'll ask you to cancel these changes and rename replit.js to index.js file.

internal/fs/utils.js:269 throw err; ^

Error: ENOENT: no such file or directory, open '/home/runner/AE-Modmail/index.js' at Object.openSync (fs.js:462:3) at Object.readFileSync (fs.js:364:35) at Object. (/run_dir/interp.js:195:19) at Module._compile (internal/modules/cjs/loader.js:999:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) at Module.load (internal/modules/cjs/loader.js:863:32) at Function.Module._load (internal/modules/cjs/loader.js:708:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) at internal/main/run_main_module.js:17:47 { errno: -2, syscall: 'open', code: 'ENOENT', path: '/home/runner/AE-Modmail/index.js' } 

Cyanic76 commented 3 years ago

index.js doesn't exist on your side.

DmanAwesome1 commented 3 years ago

index.js doesn't exist on your side.

I renamed replit.js to index.js

Cyanic76 commented 3 years ago

In the package.json file, replace replit.js with index.js (there should be 2 occurences) and rename the main file to index.js.

stale[bot] commented 3 years ago

This issue was marked as stale because it had no activity during the past 2 weeks. If this issue keeps being inactive, it will get closed in 3 days. Thanks for your contributions!

stale[bot] commented 3 years ago

This issue was closed due to inactivity. Thanks for your contributions!