mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-21 10:26:47 +00:00
Change some format usage to use %-formatting.
Minor speed increase when we're not doing excessive attribute access or any type of formatting.
This commit is contained in:
parent
86bfcdd129
commit
d24c2a09b6
@ -194,7 +194,7 @@ class GuildChannel:
|
|||||||
@property
|
@property
|
||||||
def mention(self):
|
def mention(self):
|
||||||
"""str : The string that allows you to mention the channel."""
|
"""str : The string that allows you to mention the channel."""
|
||||||
return '<#{0.id}>'.format(self)
|
return '<#%s>' % self.id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def created_at(self):
|
def created_at(self):
|
||||||
|
@ -210,7 +210,7 @@ class Client:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def dispatch(self, event, *args, **kwargs):
|
def dispatch(self, event, *args, **kwargs):
|
||||||
log.debug('Dispatching event {}'.format(event))
|
log.debug('Dispatching event %s', event)
|
||||||
method = 'on_' + event
|
method = 'on_' + event
|
||||||
handler = 'handle_' + event
|
handler = 'handle_' + event
|
||||||
|
|
||||||
|
@ -249,8 +249,8 @@ class Member(discord.abc.Messageable):
|
|||||||
def mention(self):
|
def mention(self):
|
||||||
"""Returns a string that mentions the member."""
|
"""Returns a string that mentions the member."""
|
||||||
if self.nick:
|
if self.nick:
|
||||||
return '<@!{}>'.format(self.id)
|
return '<@!%s>' % self.id
|
||||||
return '<@{}>'.format(self.id)
|
return '<@%s>' % self.id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def display_name(self):
|
def display_name(self):
|
||||||
|
@ -285,18 +285,18 @@ class Message:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
transformations = {
|
transformations = {
|
||||||
re.escape('<#{0.id}>'.format(channel)): '#' + channel.name
|
re.escape('<#%s>' % channel.id): '#' + channel.name
|
||||||
for channel in self.channel_mentions
|
for channel in self.channel_mentions
|
||||||
}
|
}
|
||||||
|
|
||||||
mention_transforms = {
|
mention_transforms = {
|
||||||
re.escape('<@{0.id}>'.format(member)): '@' + member.display_name
|
re.escape('<@%s>' % member.id): '@' + member.display_name
|
||||||
for member in self.mentions
|
for member in self.mentions
|
||||||
}
|
}
|
||||||
|
|
||||||
# add the <@!user_id> cases as well..
|
# add the <@!user_id> cases as well..
|
||||||
second_mention_transforms = {
|
second_mention_transforms = {
|
||||||
re.escape('<@!{0.id}>'.format(member)): '@' + member.display_name
|
re.escape('<@!%s>' % member.id): '@' + member.display_name
|
||||||
for member in self.mentions
|
for member in self.mentions
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,7 +305,7 @@ class Message:
|
|||||||
|
|
||||||
if self.guild is not None:
|
if self.guild is not None:
|
||||||
role_transforms = {
|
role_transforms = {
|
||||||
re.escape('<@&{0.id}>'.format(role)): '@' + role.name
|
re.escape('<@&%s>' % role.id): '@' + role.name
|
||||||
for role in self.role_mentions
|
for role in self.role_mentions
|
||||||
}
|
}
|
||||||
transformations.update(role_transforms)
|
transformations.update(role_transforms)
|
||||||
|
@ -148,7 +148,7 @@ class Role(Hashable):
|
|||||||
@property
|
@property
|
||||||
def mention(self):
|
def mention(self):
|
||||||
"""Returns a string that allows you to mention a role."""
|
"""Returns a string that allows you to mention a role."""
|
||||||
return '<@&{}>'.format(self.id)
|
return '<@&%s>' % self.id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def members(self):
|
def members(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user