-
Notifications
You must be signed in to change notification settings - Fork 0
/
NetTools.py
57 lines (50 loc) · 2.79 KB
/
NetTools.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#########################################################################################################################
# #
# #
# #
# #
# #
# #
# #
# #
# #
#########################################################################################################################
from random import randint
from discord.ext import tasks, commands
import discord
import requests
class NetTools(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def ip(self, ctx, ip: str):
try:
response = requests.get(f"https://ipinfo.io/{ip}/json").json()
embed = discord.Embed(
title="IP Address Info:", description=ip, colour=randint(1, 16777215)
)
embed.set_author(icon_url=ctx.author.avatar_url, name=str(ctx.author.name))
try:
embed.add_field(
name="Associated hostname:",
value=response["hostname"],
inline=False,
)
except:
embed.add_field(
name="Associated hostname:",
value="This address has no hostname associated.",
)
embed.add_field(
name="Location:",
value=f"[{response['city']}, {response['region']}, {response['country']}](https://google.com/maps/search/{response['loc']})",
inline=False,
)
embed.add_field(
name="Organisation/ISP:", value=response["org"], inline=False
)
await ctx.send(content=None, embed=embed)
except:
await ctx.send("Address does not exist, or is invalid.")
async def setup(bot):
await bot.add_cog(NetTools(bot))