Bot.ts
  • Introduction
  • Installation
  • Configuration
  • Migrate to v9
  • Troubleshooting
  • Command line
    • CLI Overview
    • Docker
    • Build
    • Start
    • Format
    • Lint
    • Test
    • Update
    • Readme
    • Final
  • Usage
    • Command
    • Listener
    • Button
    • Namespace
    • Cron
    • Logger
    • Paginator
    • Database
    • Caching
    • Custom types
  • Native commands
    • Eval
    • Help
    • Database
    • Terminal
    • Turn
    • Info
  • Command examples
    • Prefix
  • Utilities
    • Texts
    • Paths and URLs
    • Dates and durations
    • Special events
    • Other
  • Deployment
    • Production
    • Development
  • Contributing
    • Regulations
    • Coding Style
  • Annexes
    • Discord Support
Powered by GitBook
On this page
  • Description
  • Command pattern
  • Automatic return
  • Code blocks
  • Async / Await
  • Arguments
  • --muted
  • Annexes

Was this helpful?

  1. Native commands

Eval

Advanced eval command for bot owner tests.

PreviousCustom typesNextHelp

Last updated 6 months ago

Was this helpful?

Description

This command is surely the most useful of all, after the help command of course. It is used to execute JavaScript critical code directly on the server where the bot is located. This can be used in particular to test features or to do debugging.

The package used by this command to resolve the code is on npm as , which itself uses . These two packages are created by the creator of this framework.

Command pattern

In the Discord server where you invited the bot, use the following command pattern in a channel accessible by the bot.

.eval <code> [--muted: <boolean>]

For example:

.eval
return 42 + "0"

Automatic return

If you type your entire command on one line, you can ignore the keyword return. It will be added automatically.

.eval 42 + "0"

Code blocks

You also have the possibility to encode your code between markdown tags in order to have the indentation.

.eval ```js
return 42 + "0"
```

Async / Await

If your code contains async/await, it works at top level like on Deno!

.eval await fetch("https://api.mathjs.org/v4/?expr=42+0")

Arguments

--muted

If you want to run your code in silence, use the --muted flag (or just -m).

.eval --muted
return 42 + "0"

Annexes

Check the / section if you have a problem.

discord-eval.ts
ghom-eval
Command file
discord-eval.ts
Command
Arguments