-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.py
34 lines (30 loc) · 1.06 KB
/
lib.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
from discord.ext import commands
import discord, random, string, datetime
Data=None
##utils
#get_guild_id
def _getGuildId(message):
if not message.guild is None:
return message.guild.id
elif message.author is discord.Member:
return message.author.guild.id
else:
return message.author.id
#randomstr
def randomstr(n):
return ''.join(random.choices(string.ascii_letters + string.digits, k=n))
#Send
async def Send(ctx, content="", view=None, ephemeral=False, embed=None, mention_author=False):
options={}
if not view is None: options["view"]=view
if not embed is None: options["embed"]=embed
del_after=Data.getGuildData(_getGuildId(ctx)).getProperty("AutoRemove")
if del_after:
options["delete_after"]=int(del_after)
if hasattr(ctx, "respond"):
msg=await ctx.respond(content=content, ephemeral=ephemeral, **options)
else:
msg=await ctx.send(content=content, mention_author=mention_author, **options)
if not hasattr(msg, "edit"):
msg=await msg.original_message()
return msg