forked from hypogirl/health-bot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuser_cogs.py
73 lines (65 loc) · 3.27 KB
/
user_cogs.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
import asyncio
import discord
from discord.ext import commands
import useful
from useful import config, mod_team, club_channels
class UserCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
self._last_member = None
@commands.command()
async def timeout(self, ctx, *, arg):
time, _ = useful.get_mute_info(arg)
if not(time[0]):
await ctx.send("Please enter a valid time unit.")
return
muted_role = ctx.guild.get_role(int(config["MUTED_ROLE_ID"]))
await ctx.author.add_roles(muted_role, reason= "Self-requested timeout", atomic= True)
embed = discord.Embed(title= " ", color= 0xff0000)
embed.set_author(name= f"Enjoy your timeout. ({time[0]})")
await ctx.channel.send(embed= embed)
await asyncio.sleep(time[1])
await ctx.author.remove_roles(muted_role, reason= "Timout ended", atomic= True)
await ctx.author.send("Your timeout in HEALTHcord has ended.")
@commands.command()
@commands.has_any_role(int(config['CLUB_LEADER_ID']), *mod_team, int(config['WARBOSS_ID']))
async def pin(self, ctx, arg):
if ctx.channel.id in club_channels:
if not(ctx.message.reference):
await ctx.reply("Reply to the message you want to pin.")
else:
message_to_pin = await ctx.channel.fetch_message(ctx.message.reference.message_id)
await message_to_pin.pin(reason="Pinned by " + ctx.author.name)
await ctx.message.delete()
elif useful.check_mod(ctx):
if not(ctx.message.reference):
await ctx.reply("Reply to the message you want to pin.")
else:
message_to_pin = await ctx.channel.fetch_message(ctx.message.reference.message_id)
await message_to_pin.pin(reason="Pinned by " + ctx.author.name)
await ctx.message.delete()
@commands.command()
@commands.has_any_role(int(config['CLUB_LEADER_ID']), *mod_team, int(config['WARBOSS_ID']))
async def unpin(self, ctx, arg):
if str(ctx.channel.id) in club_channels:
if not(ctx.message.reference):
await ctx.reply("Reply to the message you want to pin.")
else:
message_to_unpin = await ctx.channel.fetch_message(ctx.message.reference.message_id)
pinned_messages = await ctx.channel.pins()
for message in pinned_messages:
if message.id == message_to_unpin.id:
await message.unpin(reason="Unpinned by " + ctx.author.name)
await ctx.message.delete()
break
elif useful.check_mod(ctx):
if not(ctx.message.reference):
await ctx.reply("Reply to the message you want to pin.")
else:
message_to_unpin = await ctx.channel.fetch_message(ctx.message.reference.message_id)
pinned_messages = await ctx.channel.pins()
for message in pinned_messages:
if message.id == message_to_unpin.id:
await message.unpin(reason="Unpinned by " + ctx.author.name)
await ctx.message.delete()
break