-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathglobals.py
57 lines (42 loc) · 1.8 KB
/
globals.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
import discord
import random
from datetime import datetime, timedelta
from time import mktime
from config import Config as cfg
db = cfg.DB.main_database
unique_collection = db.unique_collection
async def incomplete_message(ctx: discord.Interaction):
embed = discord.Embed(
title="Incomplete Command",
description="This command is undergoing development.",
color=discord.Color.red()
)
embed.set_footer(text="Use /help to see a list of commands")
await ctx.response.send_message(embed=embed)
async def developer_only(ctx: discord.Interaction, command: str):
embed = discord.Embed(
title="Developer Commmand",
description="The "f"{command}"" command is reserved for usage by CosmoBot developers only.",
color=discord.Color.red()
)
embed.set_footer(text="Use /help to see a list of commands")
await ctx.message.reply(embed=embed)
async def mod_perms(ctx: discord.Interaction):
return ctx.user.guild_permissions.moderate_members
def timestamp(time: datetime):
return f"<t:{int(mktime((time).timetuple()))}:F>"
async def no_permission(ctx: discord.Interaction, command: str):
embed = discord.Embed(
title="No Permissions",
description="You do not have the required permissions to use the "f"{command}"" command.",
color=discord.Color.red()
)
embed.set_footer(text="Use /help to see a list of commands")
await ctx.response.send_message(embed=embed)
async def gen_unique(length: int):
while True:
random_number = ''.join(random.choices('0123456789abcdefghijklmnopqrstuv', k=length))
search = await unique_collection.find_one({"friend_code": random_number})
if not search:
await unique_collection.insert_one({"unique_id": random_number})
return random_number