Socket
Socket
Sign inDemoInstall

discordbot-sync

Package Overview
Dependencies
3
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    discordbot-sync

A wrapper for the Discord API that doesn't require you to use asyncio


Maintainers
1

Readme

Discordbot

This package provides an interface to the RESTful and websocket Discord API so users don't have to worry about rate limits, asyncio, or error handling.

It's as simple as:

import discordbot as discord

bot = discord.Bot("my_api_token")

def on_message(raw_event, message):
	print(message.author, "sent a message in", message.channel, "which said", message.content)
	
	if message.content == "!ping":
		bot.send_message(message.channel, "Pong!")
bot.on_event(discord.event.guild_message_sent, on_message)

bot.run()

discordbot also provides a simple way to add commands to your bot

import discordbot as discord

bot = discord.Bot("my_api_token")

role_moderator = '00000000000000' # the id of the role which is required to use the kick command

def cmd_kick(message, member, reason):
    bot.kick(message.guild, member, reason)
    bot.send_message(message.channel, "Member %s kicked. They are allowed to re-join. Ban them if you do not want this behavior." % member, reply_to = message, reply_ping = False)
bot.register_command("kick", "Temporarily remove someone from the server", cmd_kick, required_role = role_moderator, args = [
    {
        "name": "member",
        "description": "The member to kick",
        "type": "user"
    },
    {
        "name": "reason",
        "description": "Reason for kick",
        "type": "string",
        "default": None
    }
])

bot.command_prefix = "!"

bot.register_default_commands() # (optional) adds !cmds and !ping

bot.run()

for more examples, please see this project on github

FAQs


Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc