fix(commands:getheaders|Network): prevent fails for missing [] on v6

This commit is contained in:
Romain J 2021-04-22 14:54:46 +02:00
parent 9172331927
commit 1f367fd2df
3 changed files with 11 additions and 8 deletions

View file

@ -14,7 +14,7 @@ Installing the pre-requirements
- The pre-requirements are: - The pre-requirements are:
- Python 3.9 or greater - Python 3.10 or greater
- Pip - Pip
- Git - Git
@ -118,12 +118,12 @@ Configuration
It's time to set up your first instance, to do this, you can simply It's time to set up your first instance, to do this, you can simply
execute this command: execute this command:
:bash:`tuxbot-setup [your instance name]` :bash:`tuxbot-setup`
After following the instructions, you can run your instance by executing After following the instructions, you can run your instance by executing
this command: this command:
:bash:`tuxbot [your instance name]` :bash:`tuxbot`
Update Update
------ ------

View file

@ -239,8 +239,6 @@ class Logs(commands.Cog):
if isinstance(error, (discord.Forbidden, discord.NotFound)): if isinstance(error, (discord.Forbidden, discord.NotFound)):
return return
if self.bot.instance_name != "dev":
sentry_sdk.capture_exception(error)
self.bot.console.log( self.bot.console.log(
"Command Error, check sentry or discord error channel" "Command Error, check sentry or discord error channel"
) )
@ -282,6 +280,7 @@ class Logs(commands.Cog):
e.remove_field(1) e.remove_field(1)
if self.bot.instance_name != "dev": if self.bot.instance_name != "dev":
sentry_sdk.capture_exception(error)
e.set_footer(text=sentry_sdk.last_event_id()) e.set_footer(text=sentry_sdk.last_event_id())
await ctx.send(embed=e) await ctx.send(embed=e)

View file

@ -5,7 +5,7 @@ from typing import Optional
import aiohttp import aiohttp
import discord import discord
from aiohttp import ClientConnectorError from aiohttp import ClientConnectorError, InvalidURL
from jishaku.models import copy_context_with from jishaku.models import copy_context_with
from discord.ext import commands from discord.ext import commands
from ipinfo.exceptions import RequestQuotaExceededError from ipinfo.exceptions import RequestQuotaExceededError
@ -170,7 +170,7 @@ class Network(commands.Cog):
"5": 0x343A40, "5": 0x343A40,
} }
async with ctx.session.get( async with self.bot.session.get(
str(ip), str(ip),
headers=headers, headers=headers,
timeout=aiohttp.ClientTimeout(total=8), timeout=aiohttp.ClientTimeout(total=8),
@ -202,7 +202,11 @@ class Network(commands.Cog):
e.add_field(name=key, value=value, inline=True) e.add_field(name=key, value=value, inline=True)
await ctx.send(embed=e) await ctx.send(embed=e)
except (ClientConnectorError, asyncio.exceptions.TimeoutError): except (
ClientConnectorError,
InvalidURL,
asyncio.exceptions.TimeoutError,
):
await ctx.send( await ctx.send(
_("Cannot connect to host {}", ctx, self.bot.config).format(ip) _("Cannot connect to host {}", ctx, self.bot.config).format(ip)
) )