> For the complete documentation index, see [llms.txt](https://alva-scripts.gitbook.io/alva-scripts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alva-scripts.gitbook.io/alva-scripts/as-loadingscreen.md).

# as-loadingscreen

<https://alva-scripts.com/scripts/7243673>

#### Discord Feed Bridge&#x20;

#### Security (Re~~a~~d This)

**Golden rule:** Only give the bot access to channels you want to display publicly.\
Never allow the bot to view staff/private/ticket/log channels.

***

### Requirements

* Discord bot token

***

### Discord Bot Setup

#### 1) Create a bot

Create a new application + bot in the Discord Developer Portal:\
<https://discord.com/developers/applications?new_application=true>

#### 2) Invite the bot to your server

* The bot does **not** need special permissions
* Just ensure it can **View Channel** + **Read Message History** for the channels you want to expose

![Invite Bot Screenshot](https://i.imgur.com/I03Un23.png)

#### 3) Enable Message Content Intent

Enable **Message Content Intent** so message text is available reliably:

![Enable Message Content Intent Screenshot](https://i.imgur.com/A9Ta51O.png)

#### 4) Copy your bot token

Copy the token (marked as **(1)** in the screenshot above). Keep it secret.

#### 5) Edit your scripts config:

\
Next, you just have to insert the Bot token in the server/discord\_config.lua file!\
\
Here is how it looks:

```lua
local DiscordFeedConfig = {
    enabled = false,
    botToken = "YOUR_DISCORD_TOKEN",
    guildId = "1342863880879345716", -- optional, used to build message URLs/extra validation context
    cacheSeconds = 60,
    requestTimeoutMs = 10000,

    -- make sure the ids and channelIds match what config.js has!
    feeds = {
        { id = "news",   channelId = "1470413761406959732", limit = 25, enabled = true, showAvatars = true },
        { id = "devlog", channelId = "1464942754147598473", limit = 25, enabled = true, showAvatars = true },
        { id = "events", channelId = "1464942768223944725", limit = 15, enabled = true, showAvatars = true },
    }
}
```

Also make sure, that these feeds (channeld and id) match the feeds JSON block found in `build/config.js`&#x20;

```json
  feeds: [
    {
      id: "news",
      type: "discord",
      title: "News",
      subtitle: "Latest announcements",
      enabled: true,
      discord: {
        channelId: "1470413761406959732",
        pollMs: 1000 * 180, // how often to poll for new messages (unused)
        limit: 25,
        showAvatars: true,
      },
    },
    {
      id: "devlog",
      type: "discord",
      title: "Devlog",
      subtitle: "Development updates",
      enabled: true,
      discord: {
        channelId: "1464942754147598473",
        pollMs: 1000 * 180,
        limit: 25,
        showAvatars: true,
      },
    },
    {
      id: "events",
      type: "discord",
      title: "Events",
      subtitle: "Upcoming events",
      enabled: true,
      discord: {
        channelId: "1464942768223944725",
        pollMs: 1000 * 180,
        limit: 15,
        showAvatars: true,
      },
    },
  ],
```
