[Alias] Change message deepcopy to shallow copy (#1053)

For extremely large servers (tens of thousands of members), copying the Server object can take several seconds and peg the CPU since this is a necessarily blocking operation
This commit is contained in:
Caleb Johnson 2017-11-29 14:46:37 -06:00 committed by Twentysix
parent f3c957377d
commit 4a77e764a6

View File

@ -3,7 +3,7 @@ from .utils.chat_formatting import box
from .utils.dataIO import dataIO from .utils.dataIO import dataIO
from .utils import checks from .utils import checks
from __main__ import user_allowed, send_cmd_help from __main__ import user_allowed, send_cmd_help
from copy import deepcopy from copy import copy
import os import os
import discord import discord
@ -126,7 +126,7 @@ class Alias:
if alias in self.aliases[server.id]: if alias in self.aliases[server.id]:
new_command = self.aliases[server.id][alias] new_command = self.aliases[server.id][alias]
args = message.content[len(prefix + alias):] args = message.content[len(prefix + alias):]
new_message = deepcopy(message) new_message = copy(message)
new_message.content = prefix + new_command + args new_message.content = prefix + new_command + args
await self.bot.process_commands(new_message) await self.bot.process_commands(new_message)