# $djsEval

### Usage

```php
$djsEval[showOutput;code]
```

This function has two params.

| Param      | Description                                                  | Type    | Required |
| ---------- | ------------------------------------------------------------ | ------- | -------- |
| showOutput | Whether to return the output of this code.                   | Boolean | Yes      |
| code       | The [`discord.js`](https://discord.js.org/) code to execute. | String  | Yes      |

### Examples

**Sending a Message:**

```javascript
bot.commands.add({
    type: "basicCommand",
    name: "example",
    code: `$djsEval[yes;
let result = "Hello World!"
result]` //Returns Hell
})
```

OR

```javascript
bot.commands.add({
    type: "basicCommand",
    name: "example",
    code: `$djsEval[no;d.data.message.channel.send("Hello World")]`
})
```

**Returning the Bot's Ping:**

```javascript
bot.commands.add({
    type: "basicCommand",
    name: "example",
    code: `$djsEval[yes;
let result = d.client.ws.ping + "ms"
result]`
})
```

**Getting Info About a User:**

```javascript
bot.commands.add({
    type: "basicCommand",
    name: "example",
    code: `$djsEval[yes;const user = d.client.users.cache.get("userIDHere")
let isBot = user.bot
let userTag = user.tag
let mention = user.toString()
let creationDate = "<t:" + Math.floor(user.createdTimestamp / 1000) + ":f>"
const result = isBot + " " + userTag + " " + mention + " " + creationDate 
result]` //Returns "true/false User#000 @User date"
})
```

**Getting Info About a Message:**

```javascript
bot.commands.add({
    type: "basicCommand",
    name: "example",
    code: `$djsEval[yes;
let content = d.data.message.content
let author =  d.data.message.author.id
let creationDate = "<t:" + Math.floor(d.data.message.createdTimestamp / 1000) + ":f>"
//Your code here]`
})
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dbd-ts.gitbook.io/dbdts/functions/djseval.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
