This repository has been archived by the owner on Sep 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
139 lines (122 loc) · 3.61 KB
/
main.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import uwuify
import discord
import datetime
import aiohttp
import secrets
import asyncio
from tools.bot import Pretend
from tools.helpers import PretendContext
bot = Pretend()
@bot.before_invoke
async def chunk_guild(ctx: PretendContext) -> None:
if not ctx.guild.chunked:
await ctx.guild.chunk(cache=True)
@bot.check
async def check_availability(ctx: PretendContext) -> bool:
return True
@bot.check
async def disabled_command(ctx: PretendContext):
if await ctx.bot.db.fetchrow(
"""
SELECT * FROM disablecmd
WHERE guild_id = $1
AND cmd = $2
""",
ctx.guild.id,
str(ctx.command)
):
if not ctx.author.guild_permissions.administrator:
await ctx.send_error(f"The command **{str(ctx.command)}** is **disabled** in this server")
return False
return True
global_disabled = await ctx.bot.db.fetchrow(
"""
SELECT disabled FROM global_disabled_cmds
WHERE cmd = $1
""",
ctx.bot.get_command(str(ctx.command)).name
)
if global_disabled:
if global_disabled.get("disabled") and ctx.author.id not in ctx.bot.owner_ids:
await ctx.send_warning("This command is currently disabled by the admin team of pretend, for further information please join the [Pretend Server](https://discord.gg/pretend).")
return False
return True
@bot.check
async def disabled_module(ctx: PretendContext):
if ctx.command.cog:
if await ctx.bot.db.fetchrow(
"""
SELECT FROM disablemodule
WHERE guild_id = $1
AND module = $2
""",
ctx.guild.id,
ctx.command.cog_name
):
if not ctx.author.guild_permissions.administrator:
await ctx.send_warning(f"The module **{str(ctx.command.cog_name.lower())}** is **disabled** in this server")
return False
else:
return True
else:
return True
else:
return True
@bot.check
async def restricted_command(ctx: PretendContext):
if ctx.author.id == ctx.guild.owner_id:
return True
if check := await ctx.bot.db.fetch(
"""
SELECT * FROM restrictcommand
WHERE guild_id = $1
AND command = $2
""",
ctx.guild.id,
ctx.command.qualified_name
):
for row in check:
role = ctx.guild.get_role(row["role_id"])
if not role:
await ctx.bot.db.execute(
"""
DELETE FROM restrictcommand
WHERE role_id = $1
""",
row["role_id"]
)
if not role in ctx.author.roles:
await ctx.send_warning(f"You cannot use `{ctx.command.qualified_name}`")
return False
return True
return True
@bot.tree.context_menu(name='avatar')
async def avatar_user(interaction: discord.Interaction, member: discord.Member):
"""
Get a member's avatar
"""
embed = discord.Embed(
color=await interaction.client.dominant_color(member.display_avatar.url),
title=f"{member.name}'s avatar",
url=member.display_avatar.url
)
embed.set_image(url=member.display_avatar.url)
await interaction.response.send_message(embed=embed)
@bot.tree.context_menu(name='banner')
async def banner_user(interaction: discord.Interaction, member: discord.Member):
"""
Get a member's banner
"""
member = await interaction.client.fetch_user(member.id)
if not member.banner:
return await interaction.warn(f"{member.mention} doesn't have a banner")
banner = member.banner.url
embed = discord.Embed(
color=await interaction.client.dominant_color(banner),
title=f"{member.name}'s banner",
url=banner
)
embed.set_image(url=member.banner.url)
return await interaction.response.send_message(embed=embed)
if __name__ == "__main__":
bot.run()