-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
119 lines (94 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
import nextcord
from nextcord.ext import commands
import os
from nextcord.ext.commands import CommandError
from nextcord.ext.application_checks import ApplicationMissingPermissions
from nextcord.ext.application_checks import ApplicationBotMissingPermissions
import datetime
from pymongo import MongoClient
from nextcord import ApplicationError
from motorcog import bandb
import sys
from cooldowns import CallableOnCooldown
from dotenv import load_dotenv
load_dotenv()
class IsBannedInt(ApplicationError):
def __init__(self, user, *args, **kwargs):
self.user = user
super().__init__(*args, **kwargs)
class IsInDmsInt(ApplicationError):
def __init__(self, user, *args, **kwargs):
self.user = user
super().__init__(*args, **kwargs)
intent = nextcord.Intents()
intent.guilds = True
intent.members = True
intent.bans = True
intent.emojis = True
intent.guild_messages = True
intent.message_content = True
# The bot's instance
client = commands.Bot(command_prefix=commands.when_mentioned, intents=intent, case_insensitive=True)
client.remove_command("help")
@client.event
async def on_application_command_error(interaction, error):
error = getattr(error, "original", error)
if isinstance(error, CallableOnCooldown):
await interaction.send(f"You are being **rate-limited!** Retry in `{error.retry_after}` **seconds**.",ephemeral=True)
return
if isinstance(error, IsInDmsInt):
await interaction.send("Commands can't be used in DMs", ephemeral=True)
return
if isinstance(error, IsBannedInt):
banned = await bandb.find_one({"user": interaction.user.id})
reason = banned["reason"]
embed = nextcord.Embed(description=f"Uh oh looks like you're suspended !\n**Reason :** {reason}",color=0xED4245)
embed.set_footer(text="Grabe_. team")
await interaction.send(embed=embed, ephemeral=True)
return
if isinstance(error, ApplicationMissingPermissions):
await interaction.send("You don't have permissions do that!", ephemeral=True)
return
if isinstance(error, ApplicationBotMissingPermissions):
await interaction.send(
f"I don't have permissiongs to do that!\nPermissions needed:\n> {error.missing_permissions}",
ephemeral=True)
return
else:
try:
await interaction.response.send_message("Looks like an unidentified error - This has been reported!",ephemeral=True)
except:
pass
print(error)
@client.check
def is_banned(ctx):
# Checks if the author is infinite or not
if not ctx.author.id == 742612257275641876:
return False
else:
return True
@client.application_command_check
async def is_bunned(interaction: nextcord.Interaction):
if await bandb.find_one({"user": interaction.user.id}):
raise IsBannedInt(interaction.user)
return False
else:
return True
@client.application_command_check
def dmint(interaction: nextcord.Interaction):
if interaction.user.id == 742612257275641876:
return True
if str(interaction.channel.type) == "private":
raise IsInDmsInt(interaction.user)
return False
if not str(interaction.channel.type) == "private":
return True
for folders in os.listdir("./"):
if folders.endswith("_loadable"):
sys.path.append(f"./{folders}")
for file in os.listdir(f"./{folders}"):
if file.endswith(".py"):
client.load_extension(f"{folders}.{file[:-3]}")
print(f"Successfully loaded {folders} and all cogs!")
client.load_extension('onami')
client.run(os.getenv("token"))