42 lines
1.9 KiB
Python
42 lines
1.9 KiB
Python
import json
|
|
import discord
|
|
from discord.ext import commands
|
|
from discord.errors import HTTPException, NotFound
|
|
|
|
## Xeno Discord PY Bot
|
|
### Moderation shit
|
|
extname = (f'Moderation')
|
|
|
|
class Moderation(commands.Cog):
|
|
def __init__(self, bot):
|
|
self.bot = bot
|
|
|
|
@commands.command(name='idlookup',description='looks up user info by ID')
|
|
async def idlookup(self, ctx, arg):
|
|
# await ctx.reply(f'{arg} test')
|
|
intarg = int(arg)
|
|
try:
|
|
lkupuser = await self.bot.fetch_user(intarg) # for some reason this doesnt work and i have no idea why
|
|
#await ctx.reply(f'{lkupuser} test')
|
|
except NotFound:
|
|
print(f'Cog_{extname}: idlookup for ID {arg} returned a 404')
|
|
await ctx.reply(f'A user with the ID {arg} was not found.')
|
|
except HTTPException:
|
|
print(f'Cog_{extname}: idlookup for ID {arg} returned an HTTP Exception')
|
|
await ctx.reply(f'A lookup for a user with the ID {arg} failed.')
|
|
else:
|
|
# print(f'Cog_{extname}: idlookup for ID {arg} ({self.lkupuser}) succeeded')
|
|
embed=discord.Embed(title="User ID Lookup")
|
|
if lkupuser.discriminator is "0":
|
|
embed.add_field(name='Username:', value=f'{lkupuser.name}',inline=True)
|
|
else:
|
|
embed.add_field(name='Tag:',value=f'{lkupuser.name}#{lkupuser.discriminator}',inline=True)
|
|
embed.add_field(name='Is bot/system?',value=f'{lkupuser.bot} {lkupuser.system}',inline=True)
|
|
embed.add_field(name='Creation date:',value=f'{lkupuser.created_at}',inline=True)
|
|
embed.set_thumbnail(url=lkupuser.avatar)
|
|
# embed.set_footer(f'Requestor: {ctx.message.author.name},',f'{ctx.message.author.avatar}') # idk about this yet (hash on avatar?)
|
|
await ctx.send(embed=embed)
|
|
|
|
async def setup(bot):
|
|
print(f'Cog_{extname} was initialized')
|
|
await bot.add_cog(Moderation(bot)) |