Advertisement
Geocrack

discord automute

Sep 21st, 2022 (edited)
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.50 KB | None | 0 0
  1. import discord
  2. from discord.ext import commands
  3.  
  4. intents = discord.Intents.all()
  5. bot = commands.Bot(intents=intents, command_prefix="*")
  6.  
  7.  
  8. TOKEN = ""
  9.  
  10. class settings:
  11.     muted = False
  12.     name = ""
  13.  
  14. @bot.event
  15. async def on_ready():
  16.     name_bot = bot.user.name
  17.     print(f"{'-'*45}\nDiscord Bot is online as {name_bot}\n{'-'*45}")
  18.  
  19.  
  20. @bot.command(name="mute")
  21. async def mute(ctx):
  22.     if not "Admin" in str(ctx.author.roles):
  23.         return
  24.     settings.name = ctx.author.name
  25.     print(f"All channels have been disabled by {ctx.author.name}")
  26.     message = await ctx.channel.send(f"All channels have been disabled by {ctx.author.name}")
  27.     settings.muted = True
  28.     await message.delete(delay=3)
  29.     await ctx.message.delete(delay=3)
  30.  
  31. @bot.command(name="unmute")
  32. async def unmute(ctx):
  33.     if not "Admin" in str(ctx.author.roles):
  34.         return
  35.     print(f"All channels have been unlocked by {ctx.author.name}")
  36.     message = await ctx.channel.send(f"All channels were unlocked by {ctx.author.name}")
  37.     settings.muted = False
  38.     await message.delete(delay=3)
  39.     await ctx.message.delete(delay=3)
  40.    
  41. @bot.event
  42. async def on_message(message):
  43.     await bot.process_commands(message)
  44.     if "Admin" in str(message.author.roles) or message.author == bot.user:
  45.         return
  46.     elif settings.muted:
  47.         await message.delete()
  48.         nachricht = await message.channel.send(f"All channels have been locked by {settings.name}")
  49.         await nachricht.delete(delay=3)
  50.  
  51. bot.run(TOKEN)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement