Browse Source

Fixes typos and patches raise exceptions using %s instead of .format() (#130)

pull/137/head
Dooley_labs 6 years ago
committed by Andrei Zbikowski
parent
commit
646a0437f7
  1. 6
      disco/bot/plugin.py
  2. 2
      disco/gateway/client.py
  3. 2
      disco/types/message.py
  4. 6
      disco/util/functional.py
  5. 2
      disco/util/serializer.py
  6. 2
      disco/voice/client.py
  7. 2
      disco/voice/playable.py
  8. 10
      docs/bot_tutorial/building_block_listeners.md

6
disco/bot/plugin.py

@ -66,7 +66,7 @@ def find_loadable_plugins(mod):
class BasePluginDeco(object): class BasePluginDeco(object):
Prio = Priority Prio = Priority
# TODO: dont smash class methods # TODO: don't smash class methods
@classmethod @classmethod
def add_meta_deco(cls, meta): def add_meta_deco(cls, meta):
def deco(f): def deco(f):
@ -234,7 +234,7 @@ class Plugin(LoggingClass, PluginDeco):
self.storage = bot.storage self.storage = bot.storage
self.config = config self.config = config
# General declartions # General declarations
self.listeners = [] self.listeners = []
self.commands = [] self.commands = []
self.schedules = {} self.schedules = {}
@ -445,7 +445,7 @@ class Plugin(LoggingClass, PluginDeco):
repeat : bool repeat : bool
Whether this schedule is repeating (or one time). Whether this schedule is repeating (or one time).
init : bool init : bool
Whether to run this schedule once immediatly, or wait for the first Whether to run this schedule once immediately, or wait for the first
scheduled iteration. scheduled iteration.
kwargs: dict kwargs: dict
kwargs which will be passed to executed `func` kwargs which will be passed to executed `func`

2
disco/gateway/client.py

@ -194,7 +194,7 @@ class GatewayClient(LoggingClass):
if isinstance(error, KeyboardInterrupt): if isinstance(error, KeyboardInterrupt):
self.shutting_down = True self.shutting_down = True
self.ws_event.set() self.ws_event.set()
raise Exception('WS recieved error: %s', error) raise Exception('WS received error: {}'.format(error))
def on_open(self): def on_open(self):
if self.zlib_stream_enabled: if self.zlib_stream_enabled:

2
disco/types/message.py

@ -346,7 +346,7 @@ class Message(SlottedModel):
IDs for roles mentioned within this message. IDs for roles mentioned within this message.
embeds : list[`MessageEmbed`] embeds : list[`MessageEmbed`]
Embeds for this message. Embeds for this message.
attachments : list[`MessageAttachment`] attachments : dict[`MessageAttachment`]
Attachments for this message. Attachments for this message.
reactions : list[`MessageReaction`] reactions : list[`MessageReaction`]
Reactions for this message. Reactions for this message.

6
disco/util/functional.py

@ -9,10 +9,10 @@ def take(seq, count):
Args Args
---- ----
seq : sequnce or generator seq : sequence or generator
The sequnce to take elements from. The sequence to take elements from.
count : int count : int
The number of elments to take. The number of elements to take.
""" """
for _ in range(count): for _ in range(count):
i = next(seq, NO_MORE_SENTINEL) i = next(seq, NO_MORE_SENTINEL)

2
disco/util/serializer.py

@ -12,7 +12,7 @@ class Serializer(object):
@classmethod @classmethod
def check_format(cls, fmt): def check_format(cls, fmt):
if fmt not in cls.FORMATS: if fmt not in cls.FORMATS:
raise Exception('Unsupported serilization format: {}'.format(fmt)) raise Exception('Unsupported serialization format: {}'.format(fmt))
@staticmethod @staticmethod
def json(): def json():

2
disco/voice/client.py

@ -406,7 +406,7 @@ class VoiceClient(LoggingClass):
channel_id = self.server_id channel_id = self.server_id
if not channel_id: if not channel_id:
raise VoiceException('[%s] cannot connect to an empty channel id', self) raise VoiceException('[{}] cannot connect to an empty channel id'.format(self))
if self.channel_id == channel_id: if self.channel_id == channel_id:
if self.state == VoiceState.CONNECTED: if self.state == VoiceState.CONNECTED:

2
disco/voice/playable.py

@ -12,7 +12,7 @@ from disco.voice.opus import OpusEncoder
try: try:
from cStringIO import cStringIO as BufferedIO from io import StringIO as BufferedIO
except ImportError: except ImportError:
if six.PY2: if six.PY2:
from StringIO import StringIO as BufferedIO from StringIO import StringIO as BufferedIO

10
docs/bot_tutorial/building_block_listeners.md

@ -1,6 +1,6 @@
# Listeners # Listeners
Listeners provide an API to listen to and execute code upon the occurance of specified Discord events. Listeners provide an API to listen to and execute code upon the occurrence of specified Discord events.
## Listener Basics ## Listener Basics
@ -28,7 +28,7 @@ To see all the events you can subscribe too, checkout the [gateway events list](
## Listener Priority ## Listener Priority
Each listener thats registered comes with a priority. This priority describes how the builtin event emitter will distribute events to your listener. To set a priority you can simply pass the priority kwarg: Each listener that's registered comes with a priority. This priority describes how the builtin event emitter will distribute events to your listener. To set a priority you can simply pass the priority kwarg:
```py ```py
from holster.emitter import Priority from holster.emitter import Priority
@ -43,6 +43,6 @@ def on_guild_member_add(self, event):
| Name | Description | | Name | Description |
|------|-------------| |------|-------------|
| BEFORE | Recieves all events sequentially alongside the emitter. This is the most dangerous priority level, as any executed code will block other events in the emitter from flowing. Blocking within a BEFORE handler can be lethal. | | BEFORE | Receives all events sequentially alongside the emitter. This is the most dangerous priority level, as any executed code will block other events in the emitter from flowing. Blocking within a BEFORE handler can be lethal. |
| SEQUENTIAL | Recieves all events sequentially, but within a seperate greenlet. This priority level can be used for plugins that require sequential events but may block or take a long time to execute their event handler. | | SEQUENTIAL | Receives all events sequentially, but within a separate greenlet. This priority level can be used for plugins that require sequential events but may block or take a long time to execute their event handler. |
| NONE | This priority provides no guarentees about the ordering of events. Similar to SEQUENTIAL all event handlers are called within a seperate greenlet. | | NONE | This priority provides no guarantees about the ordering of events. Similar to SEQUENTIAL all event handlers are called within a separate greenlet. |

Loading…
Cancel
Save