Skip to content

Commit 19a4878

Browse files
committed
Changed how logger is passed
1 parent 675e09c commit 19a4878

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

discord_slash/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ def __init__(self,
3131
self._discord = client
3232
self.commands = {}
3333
self.subcommands = {}
34-
self.req = http.SlashCommandRequest()
3534
self.logger = logging.getLogger("discord_slash")
35+
self.req = http.SlashCommandRequest(self.logger)
3636
self.auto_register = auto_register
3737
if self.auto_register:
3838
self.logger.warning("auto_register is NOT implemented! Please manually add commands to Discord API.")
@@ -290,7 +290,7 @@ async def on_socket_response(self, msg):
290290
to_use = msg["d"]
291291
if to_use["data"]["name"] in self.commands.keys():
292292
selected_cmd = self.commands[to_use["data"]["name"]]
293-
ctx = model.SlashContext(self.req, to_use, self._discord, self)
293+
ctx = model.SlashContext(self.req, to_use, self._discord, self.logger)
294294
if selected_cmd["guild_ids"]:
295295
if ctx.guild.id not in selected_cmd["guild_ids"]:
296296
return

discord_slash/model.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class SlashContext:
1818
:ivar command_id: ID of the command.
1919
:ivar _http: :class:`.http.SlashCommandRequest` of the client.
2020
:ivar _discord: :class:`discord.ext.commands.Bot`
21-
:ivar slashcommand: :class:`.client.SlashCommand`
21+
:ivar logger: Logger instance.
2222
:ivar sent: Whether you sent the initial response.
2323
:ivar guild: :class:`discord.Guild` instance of the command message.
2424
:ivar author: :class:`discord.Member` instance representing author of the command message.
@@ -29,14 +29,14 @@ def __init__(self,
2929
_http: http.SlashCommandRequest,
3030
_json: dict,
3131
_discord: typing.Union[discord.Client, commands.Bot],
32-
slashcommand):
32+
logger):
3333
self.__token = _json["token"]
3434
self.name = _json["data"]["name"]
3535
self.interaction_id = _json["id"]
3636
self.command_id = _json["data"]["id"]
3737
self._http = _http
3838
self._discord = _discord
39-
self.slashcommand = slashcommand
39+
self.logger = logger
4040
self.sent = False
4141
self.guild: discord.Guild = _discord.get_guild(int(_json["guild_id"]))
4242
self.author: discord.Member = self.guild.get_member(int(_json["member"]["user"]["id"])) if self.guild else None
@@ -100,7 +100,7 @@ async def send(self,
100100
else:
101101
base["data"]["flags"] = 64
102102
if hidden and embeds:
103-
self.slashcommand.logger.warning("You cannot use both `hidden` and `embeds`!")
103+
self.logger.warning("You cannot use both `hidden` and `embeds` at the same time!")
104104
initial = True if not self.sent else False
105105
resp = await self._http.post(base, self._discord.user.id, self.interaction_id, self.__token, initial)
106106
self.sent = True

0 commit comments

Comments
 (0)