-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util_member.py
50 lines (42 loc) · 2.48 KB
/
util_member.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
from discord.ext import commands
from discord import app_commands
from util_discord import command_check, description_helper
async def avatar_function(ctx: commands.Context, bot: commands.Bot, arg: str):
if await command_check(ctx, "av", "utils"): return await ctx.reply("command disabled", ephemeral=True)
if arg and not arg.isdigit(): return await ctx.reply("Must be a valid user ID.")
try:
user = await bot.fetch_user(int(arg) if arg else ctx.author.id)
if user and user.avatar: return await ctx.reply(user.avatar.url)
except: pass
await ctx.reply("There is no such thing.")
async def banner_function(ctx: commands.Context, bot: commands.Bot, arg: str):
if await command_check(ctx, "ban", "utils"): return await ctx.reply("command disabled", ephemeral=True)
if arg and not arg.isdigit(): return await ctx.reply("Must be a valid user ID.")
try:
user = await bot.fetch_user(int(arg) if arg else ctx.author.id)
if user and user.banner: return await ctx.reply(user.banner.url)
except: pass
await ctx.reply("There is no such thing.")
class DiscordUtilMember(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.hybrid_command(description=f'{description_helper["emojis"]["utils"]} {description_helper["utils"]["banner"]}')
@app_commands.describe(user_id="User ID of the user you want to see the banner of")
@app_commands.allowed_installs(guilds=True, users=True)
@app_commands.allowed_contexts(guilds=True, dms=True, private_channels=True)
async def banner(self, ctx: commands.Context, *, user_id:str=None):
await banner_function(ctx, self.bot, user_id)
@commands.hybrid_command(description=f'{description_helper["emojis"]["utils"]} {description_helper["utils"]["avatar"]}')
@app_commands.describe(user_id="User ID of the user you want to see the avatar of")
@app_commands.allowed_installs(guilds=True, users=True)
@app_commands.allowed_contexts(guilds=True, dms=True, private_channels=True)
async def avatar(self, ctx: commands.Context, *, user_id:str=None):
await avatar_function(ctx, self.bot, user_id)
@commands.command()
async def av(self, ctx: commands.Context, *, user_id:str=None):
await avatar_function(ctx, self.bot, user_id)
@commands.command()
async def ban(self, ctx: commands.Context, *, user_id:str=None):
await banner_function(ctx, self.bot, user_id)
async def setup(bot: commands.Bot):
await bot.add_cog(DiscordUtilMember(bot))