DiSky DiSky v5.0.0-b1

Listing and events

guide

Intercept every command before its checks run, list every one that's loaded, and log each use.

commandsevents

This page covers on discord command used, the event every command goes through before its checks, and listing the commands currently loaded. You're assumed to have a bot named "my-bot" logged in.

Intercepting a command

fires for every command, before executable in, roles, permissions and cooldown are even checked. cancel event inside it stops the command outright, before its trigger ever runs; it is one of the two cancellable DiSky events.

discord command blocked:
    prefixes: "!"
    trigger:
        reply with "this should never run"

on discord command used:
    if name of event-discordcommand is "blocked":
        cancel event
        reply with "blocked by 'on discord command used'"

event-discordcommand is the command, and used prefix, used alias, used arguments say exactly how it was typed; the same three expressions work inside the command's own trigger. Filter to one bot the usual way, with on discord command used seen by "my-bot":.

Log every use the same way, before any check can refuse it:

on discord command used:
    send "%event-user% ran %name of event-discordcommand% (prefix=%used prefix%, alias=%used alias%, args='%used arguments%')" to console
event Discord Command UsedEventsdiscord command (use|used|invoked)Fired when a message matches a 'discord command' structure, before its checks (channel, roles, permissions, cooldown) and before its trigger runs. Cancel it to stop the command entirely. 'event-discordcommand' is the command, 'used prefix' / 'used alias' / 'used arguments' tell how it was typed.since 5.0.0-a1

Listing commands

returns every command loaded from every script, as a list of values. Each one exposes its declared entries, read-only:

Property

Returns

the command's name

the description entry, if set

the usage entry, or one generated from the name and arguments

the category entry, if set

the command's aliases, without its main name

the command's prefixes; empty when it answers to its bare name

the cooldown entry, if set

discord command help:
    prefixes: "!"
    trigger:
        set {_lines::*} to ""
        loop all discord commands:
            add "%name of loop-value%: %usage of loop-value%" to {_lines::*}
        reply with join {_lines::*} with nl

Group the reply by category of loop-value once you have more than a handful of commands. The list always matches what's currently loaded: reloading a script adds or removes its commands from it immediately, without restarting the bot.

expression All Discord CommandsCore · Expressions[all [of]] [the] [registered] discord commandsEvery 'discord command' currently loaded, from every script.list of Discord Commandsince 5.0.0-a1 Discord Command type 7 syntaxes A command declared with the 'discord command' structure. Available as 'event-discordcommand' in its trigger and in the 'discord command used' / 'failed' events, or through 'all discord commands'.
Was this page helpful?
An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.