-
Notifications
You must be signed in to change notification settings - Fork 36
/
lockdown.py
60 lines (45 loc) · 1.65 KB
/
lockdown.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
import logging
import discord
from discord.ext import commands
import utils
import settings
logger = logging.getLogger(__name__)
ROLES = [1035163844064071720]
def run():
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
@bot.event
async def on_ready():
logging.info(f"User: {bot.user} (ID: {bot.user.id})")
await utils.load_videocmds(bot)
async def enable_lockdown(guild, is_lockdown=True):
for role in guild.roles:
if role.id in ROLES:
current_permissions = role.permissions
if is_lockdown:
current_permissions.update(
send_messages=False,
use_application_commands=False,
send_messages_in_threads=False,
)
else:
current_permissions.update(
send_messages=True,
use_application_commands=True,
send_messages_in_threads=True,
)
await role.edit(permissions=current_permissions)
@bot.command()
async def lockdown(ctx: commands.Context):
guild = ctx.message.guild
await enable_lockdown(guild)
await ctx.send("The server is in lockdown")
@bot.command()
async def unlock(ctx: commands.Context):
guild = ctx.message.guild
await enable_lockdown(guild, False)
await ctx.send("The lockdown is over.")
bot.run(settings.DISCORD_API_SECRET, root_logger=True)
if __name__ == "__main__":
run()