示例#1
0
文件: bot.py 项目: ekgame/discord-py
class DiscordBot(DiscordClient):
    def __init__(self, email, password):
        super().__init__(email, password)
        self.command_handler = CommandHandler()
        self.register_command(["roll"], CommandRoll())
        self.plugins = []

    def register_command(self, labels, command):
        self.command_handler.add_command(labels, command)

    def register_plugin(self, plugin):
        self.plugins.append(plugin)

    def on_ready(self):
        for plugin in self.plugins:
            plugin.on_ready()

    def on_message_create(self, event):
        for plugin in self.plugins:
            plugin.on_message_create(event)

        if event.content.strip().startswith("//"):
            self.command_handler.handle_command(event.content, CommandContext(event.get_channel(), event.user))
示例#2
0
class DiscordBot(DiscordClient):
    def __init__(self, email, password):
        super().__init__(email, password)
        self.command_handler = CommandHandler()
        self.register_command(["roll"], CommandRoll())
        self.plugins = []

    def register_command(self, labels, command):
        self.command_handler.add_command(labels, command)

    def register_plugin(self, plugin):
        self.plugins.append(plugin)

    def on_ready(self):
        for plugin in self.plugins:
            plugin.on_ready()

    def on_message_create(self, event):
        for plugin in self.plugins:
            plugin.on_message_create(event)

        if event.content.strip().startswith("//"):
            self.command_handler.handle_command(
                event.content, CommandContext(event.get_channel(), event.user))
示例#3
0
文件: bot.py 项目: ekgame/discord-py
 def __init__(self, email, password):
     super().__init__(email, password)
     self.command_handler = CommandHandler()
     self.register_command(["roll"], CommandRoll())
     self.plugins = []
示例#4
0
 def __init__(self, email, password):
     super().__init__(email, password)
     self.command_handler = CommandHandler()
     self.register_command(["roll"], CommandRoll())
     self.plugins = []