--! Previous: -
--! Hash: sha1:183d67042c756db13c07c3f3c6b8bd5301d47239
--! Message: DiscordChannel table

--- Table used to manage Discord channels known to the server and permissions thereon.
CREATE TABLE IF NOT EXISTS DiscordChannel
(
    --- The ID of the channel in Discord, as a decimal string.
    discordId           VARCHAR(20) PRIMARY KEY NOT NULL,
    --- The last known name of this channel.
    name                VARCHAR(100)            NOT NULL,
    --- True if this channel should be used to broadcast public game events.
    broadcastGame       BOOLEAN                 NOT NULL DEFAULT FALSE,
    --- True if this channel should be used to send logs.
    sendLogs            BOOLEAN                 NOT NULL DEFAULT FALSE,
    --- True if this channel can accept game commands.
    acceptGameCommands  BOOLEAN                 NOT NULL DEFAULT FALSE,
    --- True if this channel can accept admin commands.
    acceptAdminCommands BOOLEAN                 NOT NULL DEFAULT FALSE,
    --- The priority of this channel when slowing down to account for rate limits. Higher is more important.
    priority            SMALLINT                NOT NULL DEFAULT 0,
    --- The snowflake ID of the guild in which this channel exists, if it's known.
    guildId             VARCHAR(20)                      DEFAULT NULL,
    --- The snowflake ID of the webhook used to post to this channel. Nulled out if the webhook 404s.
    webhookId           VARCHAR(20)                      DEFAULT NULL,
    --- The webhook token used to post to this channel. Nulled out if the webhook 404s.
    webhookToken        VARCHAR(20)                      DEFAULT NULL,
    --- Verifies that the webhook ID and token are always set or unset together.
    CONSTRAINT DiscordChannel_WebhookPair CHECK (
            (webhookId IS NULL AND webhookToken IS NULL)
            OR (webhookId IS NOT NULL AND webhookToken IS NOT NULL))
);
