Custom Databases

Last updated: Mar 11th, 2017

Introductions

Custom databases can be used to create your own games, keep track of scores. Give people cash and allow them to win stuff, or perhaps a warning system before kicking someone, and many more possibilities.

Create Database

Creates a blank database!
.create -db dbname

View Database

.view -db dbname

Wipe Database

Resets a database as if you just created it!
.wipe -db dbname

Delete Database

.delete -db dbname

List Databases

.viewdbs

Create Variable


.auto .make={init}
{m?dbname:varname} := value

Edit Variable

Assuming your variable has a value that is an integer (number) Let's increment it by 1

.auto .test={init}
{e?dbname:varname(++)}You have been warned!
Now let's get a little harder as we go down. let's add a custom number.

.auto .test={init}
{e?dbname:varname(+32)}You have earned 32 points

.auto .test={init}
{e?dbname:varname(-32)}You have lost 32 points
Alright that's neat, but let's step it up. It can get wild.

.auto .test={init}
{e?dbname:varname(+{rand:1,50})}You have gained `{rand:1,50}` points.

.auto .test={init}
{e?dbname:varname(-{rand:1,50})}You have lost `{rand:1,50}` points.
Neat? That's not all though we can take it a step further with maths!

.auto .test={init}
{e?dbname:varname(+{math:{rand:1,5}*10})}You have gained `{math:{rand:1,5}*10}` points.

.auto .test={init}
{e?dbname:varname(-{math:{rand:1,5}*10})}You have lost `{math:{rand:1,5}*10}` points.

Appending value

Appends text to the end of value (Known to be buggy)

.auto .test={init}
{e?dbname:varname(.=Hello!)}

Delete from value

Deletes text from value (Known to be buggy)

.auto .test={init}
{e?dbname:varname(text...)} /* Leave the ... at the end as it's required */

Delete Variable


.auto .remove={init}
{d?dbname:varname} /* Deletes varname from dbname */

Using Variable

Here's an Example using D.S.S In this example we will use Discord IDs as the variables.
And we're work on a warning system that kicks after 3 warns.

.auto .tst={init}
/* Check if variable exists in database */
DB:dbname.{rawid}?:{ars:tst2}
Response.nil?:You have been added to the database.{m?dbname:{rawid}}:=0
Now lets create the second rule we're linking to.

.auto tst2={init}
{arslock} /* lock rule to A.R.S Linking only */
/* Check the count of varname */
/* If the user has been warned 3 times kick them */
/* And remove them from the database/ */
Count.{r?dbname:{rawid}} >= 3?:{kick}{d?dbname:{rawid}} /* Final warning kick the user */
Response.nil?:{e?dbname:{rawid}(++)}A Warning has been added!

List Elements

We're going to show you how to manipulate arrays (Lists) through Echo ARS.
First Step would be to make the variable.

.auto .tst={init}
/* Check if variable exists in database */
{m?Database:Varname} := 
Now we need to populate the array. You can do this manually or as shown below with a command.

.auto &.addvar {params}={init}
/* Check to see if the word exists in the array */
String.{le?Database:Varname({params})}?:This word already exists in the array.
Response.nil?:{la?Database:Varname({params})}The word has been added to the array.
Ok, now let's create the delete command to remove words of the array.

.auto &.delvar {params}={init}
/* Check to see if the word exists in the array */
String.{le?Database:Varname({params})}?:This word doesn't exists in the array.
Response.nil?:{ld?Database:Varname({params})}The word has been removed from the array.
Awesome! Now you know how to Add\Delete & Check if a word exists inside of an array. But we do have some more, let's check out different ways to view the array.

.auto .viewall={init}
/* We're going to use the \n as a seperator. This can be changed to anything */
```
{lr?Database:Varname(\n)}
```
Awesome, but what if you only want to view one item from the array?
This can be done using Indexes let's assume there are 3 items in the array
morning,night,day

.auto &.v {params}={init}
```
{lr?Database:Varname[{params}]}
```
Notice the above is using an index system not a seperation system.
So if you type .v 2 echo will respond with day
And if you type .v 0 echo will respond with morning
Let's take a look at radomly choosing from an array

.auto .random={init}
`{lrp?Database:Varname}`
There you have it! All of the new array keys with tons of different possibilities.

Some Examples

Verify System

Will force new members to verify in your general channel a 4 digit number before x time.
If they don't verify in time Echo will kick them from your server.
REQUIREMENTS:
Create Role: Member
Create Role: Unverified
Create Database: verify
Total of 3 Rules total

First Rule:
.auto jnverify={init}
{Event:Join}
{pm}Welcome {/user} you are required to type a captcha in the next 3 minutes.
In our general channel please type `.verify {rand:1000,9999}`. If you don't you will be kicked from the server.
{m?verify:{rawid}} := {rand:1000,9999}
{ars:verSniffer}
Second Rule:
.auto verSniffer={init}
{arslock}
{sleep:3m}
DB:verify.{rawid}?:{/user} you failed to type the captcha Goodbye! {kick}
Response.nil?:A Final PM Message goes here (Usually a website or information about your server) {take:Unverified}
Final Rule:

The main .verify command. Make sure to change the 2 minutes to whatever you have set for the sleep in the Second rule.

.auto &.verify {params}={init}
Params.{r?verify:{rawid}}?:Thank you for verifying with `eCAPTCHA` Please wait while we transfer you from `Unverified` to `Member`. This could take up to 2 minutes.. {d?verify:{rawid}}{role:Member}
Response.nil?:Verification code is incorrect. Please try again.

SysResponses

Custom Responses

Since the closing of our Web manager we've needed another way for custom responses.
This system works using a custom database named SysResponses the code is below.
Save the JSON to a file named SysResponses.edb and than drag the file to your server.
If everything worked, Echo will notify you of the installation of your new database.
And all of Echos preset responses will be updated to what you choose!
SysResponses.edb

{
   "NoRole":         "I couldn't find the role `{data}` Check your spelling.",
   "AddMaster":      "I have added {user} as a Bot Commander.",
   "DelMaster":      "I have removed {user} from Bot Commander.",
   "Prefix":         "I have changed the Prefix to {data}",
   "GreetMsg":       "I have changed the Greeting to `{data}`",
   "GreetOff":       "I have turned the Greet Message `off`",
   "ByeMsg":         "I have changed the Bye to `{data}`",
   "ByeOff":         "I have turned the Bye Message `off`",
   "Autorole":       "New people will get the role `{data}`",
   "AutoroleOff":    "Autorole => `Disabled`",
   "SetPunish":      "I have changed the punishment of Antilinks and Warning system to `{data}`",
   "SetPunishError": "You need to pick a proper punishment: ban/kick/warn",
   "Give":           "I have given {user} the role `{data}` Bitches!",
   "Take":           "I have taken the role `{data}` from {user}",
   "IPError":        "`Error:` Not a valid IP or Domain name.",
   "NoRolePerms":    "I wasn't able to pull the roles from your server. Check my permissions!",
   "RoleNoExist":    "This role doesn't Exist.",
   "DenyLinks":      "Links are no longer allowed on this server",
   "AllowLinks":     "Links are now allowed on this server.",
   "AntiLinkKick":   "I have kicked {user} for advertising.",
   "AntiLinkBan":    "I have banned {user} for advertising.",
   "AntiLinkWarn":   "{user} Advertising is not allowed on this server!",
   "Kick":           "I have kicked {user} from the server.",
   "Ban":            "I have banned {user} from the server."
}

Or you could edit your responses by creating a command.
.auto &.response {params}={init}
{split: - }
Response Edited!
{m?SysResponses:{/p0}} := {/p1}
Use the above command like:
.response Give - {user} now has the role `{data}`
.response AntiLinkKick - {user} has been kicked for advertising.

SysARS

Disabling ARS Rules

This database was designed to temporarily disable your A.R.S Rules.
This system works using a custom database named SysARS the code is below.

By adding the trigger name to the database with the value of false your rule will no longer work.
You will need to remove the variable inside of the database in order for the A.R.S Rule to work again.
SysARS.edb

{
   ".helloworld":   "false"
}