Bot Interaction

Building Discord bots using the discord Python library is a simple affair. After importing the discord library into your Python script, you just need to instantiate a bot object and pass it the token that was generated during your bot’s application configuration. The discord Python library utilizes a cool Python feature called decorators[89] that acts like a function or class, wrapping another function or class and changing its behavior. Not only does this allow chaining of multiple functions and classes, but the decorator syntax keeps Python code from bloating with unnecessary complexity and verbosity.

For our Discord RedditBot, we need it to respond to three different inputs:

  • !list
  • !hide
  • !clear

!list will call the subreddit submission ...

Get Portable Python Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.