Added error handling at auto convert
@@ -249,7 +249,11 @@ class SlashCommand:
return [x["value"] for x in options]
if not auto_convert:
return [x["value"] for x in options]
- converters = [guild.fetch_member, guild.get_channel, guild.get_role]
+ converters = [
+ [guild.get_member, guild.fetch_member],
+ guild.get_channel,
+ guild.get_role]
+
types = {
"user": 0,
"USER": 0,
@@ -274,9 +278,19 @@ class SlashCommand:
to_return.append(selected["value"])
continue
loaded_converter = converters[types[auto_convert[selected["name"]]]]
+ if isinstance(loaded_converter, list):
+ cache_first = loaded_converter[0](int(selected["value"]))
+ if cache_first:
+ to_return.append(cache_first)
+ continue
+ loaded_converter = loaded_converter[1]
+ try:
to_return.append(await loaded_converter(int(selected["value"]))) \
if iscoroutinefunction(loaded_converter) else \
to_return.append(loaded_converter(int(selected["value"])))
+ except (discord.Forbidden, discord.HTTPException):
+ self.logger.warning("Failed fetching user! Passing ID instead.")
+ to_return.append(int(selected["value"]))
return to_return
async def on_socket_response(self, msg):
