-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutil.py
51 lines (44 loc) · 1.5 KB
/
util.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
import asyncio
import discord
from discord.ext.buttons import Paginator
class Pag(Paginator):
async def teardown(self):
try:
await self.page.clear_reactions()
except discord.HTTPException:
pass
async def GetMessage(
bot, ctx, contentOne="Default Message", contentTwo="\uFEFF", timeout=100
):
"""
This function sends an embed containing the params and then waits for a message to return
Params:
- bot (commands.Bot object) :
- ctx (context object) : Used for sending msgs n stuff
- Optional Params:
- contentOne (string) : Embed title
- contentTwo (string) : Embed description
- timeout (int) : Timeout for wait_for
Returns:
- msg.content (string) : If a message is detected, the content will be returned
or
- False (bool) : If a timeout occurs
"""
embed = discord.Embed(title=f"{contentOne}", description=f"{contentTwo}",)
sent = await ctx.send(embed=embed)
try:
msg = await bot.wait_for(
"message",
timeout=timeout,
check=lambda message: message.author == ctx.author
and message.channel == ctx.channel,
)
if msg:
return msg.content
except asyncio.TimeoutError:
return False
def clean_code(content):
if content.startswith("```") and content.endswith("```"):
return "\n".join(content.split("\n")[1:])[:-3]
else:
return content