Giter Site home page Giter Site logo

pinbot's Introduction

Pinbot

Install ๐Ÿ“Œ

Join the Pinbot Discord Server

Whenever you react to a message with a pushpin ๐Ÿ“Œ emoji, Pinbot posts the message to a channel.

Example of a Pinbot message

Pinbot is designed as an extension to Discord's channel pins system. Use Pinbot to:

  • Bypass Discord's 50-pin limit and create a historic stream of all your pins
  • Collect all your server's pins into one place (with optional overrides)
  • Give your server's pins a more permanent home

Why does this exist?

Discord guilds use pins for a lot more than just highlighting important information. In fact, many guilds use the pin system as a form of memorialising a good joke, a savage putdown, or other memorable moments. As a result, the 50 pin per channel limit means that in order to keep something, you will eventually have to get rid of something else.

How does it work?

Pinbot uses the channel name to decide where it will post. In order of priority it will pin in:

  1. #{channel}-pins, where channel is the name of the channel the message was pinned in
  2. #pins, a general pins channel
  3. #{channel}, the channel the pin was posted in, so that if you don't want a separate pins channel you can instead search for pins by @pinbot in the channel

Whenever Pinbot pins a message, or whenever you update the actual channel pins, Pinbot will trigger a reimport of all the channel's pins. You can also trigger this manually with the /import command.

Don't forget that pinbot needs permission to see and post in these channels, otherwise it won't be able to do its job.

โš ๏ธ Note that this bot is currently in beta. There may be bugs, please report them โš ๏ธ

Emojis

Pinbot will react with the following emojis to provide feedback:

Emoji Meaning
๐Ÿ‘€ Pinbot has seen your message and is currently processing it
โœ… Pinbot has successfully pinned your message
๐Ÿ’ฉ Pinbot could not perform an action for an unspecified reason
๐Ÿ”„ Pinbot could not pin their own message. Pinbot hates recursion
๐Ÿšซ Pinbot could not pin this message as it was in an excluded channel (only really applicable to self-hosted Pinbots)

Permissions

Pinbot is designed to be run with as few permissions as possible, however as part of its core functionality it needs to be able to read the contents of messages in your server. If you're not cool with this then you're welcome to audit the code yourself, or host and run your own Pinbot.

Pinbot requires the following permissions to function in any channels you intend to use it:

  • Read messages (VIEW_CHANNEL)
  • Send messages (SEND_MESSAGES)
  • Add reactions (ADD_REACTIONS)

Run

Pinbot is designed to be run as the managed application above, but if you prefer (or if you don't trust a bot with permission to read and relay your messages) you can run your own. You will need to create a new bot, obtain the token and application ID, and install the bot to your server (Pinbot will output a link to install the bot to your servers in the "Starting Pinbot" message when it's run).

Part of the build pipeline includes building a Docker image which is pushed to ghcr.

export TOKEN {bot_token}
export APPLICATION_ID {bot_application_id}
docker run -e TOKEN -e APPLICATION_ID ghcr.io/elliotwms/pinbot:{version}

Configuration

Variable Description Required
TOKEN Bot token ID true
APPLICATION_ID Bot application ID true
TEST_GUILD_ID When specified, the bot should only respond to pins in this test guild false
HEALTH_CHECK_ADDR Address to serve the /v1/health/ endpoint on (e.g. :8080) false
EXCLUDED_CHANNELS Comma-separated list of excluded channel IDs false
LOG_LEVEL Log level. trace enables discord-go debug logs false

Testing

/tests contains a suite of integration tests which run against the real Discord API in a test guild. It will create and destroy a guild for the test run (unless you specify a TEST_GUILD_ID, in which case it will use an existing one, as explained below).

In order to run these test yourself you will need to:

  • Create a new bot, obtaining the bot token
  • Run the tests with the TOKEN and APPLICATION_ID environment variables

Set the TEST_DEBUG environment variable in order to enable debug logging in tests.

Debugging

If you would rather view the bot activity, then it's also possible to use an existing guild instead of creating and destroying one for each test run.

  • Invite your bot to your guild, giving it the usual bot permissions as well additional permissions required to run the tests. A link will be output at the start of the tests to install the bot which requests the base permissions along with the following:
    • Manage Channels (to create channels during tests)
    • Read Messages (to assert on message creation)
    • Manage messages (to pin messages)
  • Set the TEST_GUILD_ID environment variable to the test guild's ID when running the tests as above

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.