Last active
July 25, 2020 12:37
-
-
Save chiragmatkar/a1830e2c56c8bd4a1bcea48d95d5ed59 to your computer and use it in GitHub Desktop.
A bot to nuke all messages of private channel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import discord | |
| from dotenv import load_dotenv | |
| import sys | |
| load_dotenv() | |
| TOKEN = os.getenv('DISCORD_TOKEN') | |
| SERVER_ID = os.getenv('SERVER_ID') | |
| print(SERVER_ID) | |
| client = discord.Client() | |
| blue = '\x1b[1;36m' | |
| green = '\x1b[1;32m' | |
| clear = '\x1b[0m' | |
| @client.event | |
| async def on_ready(): | |
| welcome = "logged in as {0.name} - {0.id}".format(client.user) | |
| print(welcome) | |
| sentdex_guild = client.get_guild(int(SERVER_ID)) | |
| if sentdex_guild: | |
| print("Server found = ["+str(sentdex_guild)+"]") | |
| for c in sentdex_guild.text_channels: | |
| await wipe(c) | |
| else: | |
| print("No Server found.exiting...") | |
| sys.exit(0) | |
| async def wipe(channel): | |
| print("[{}*{}] Starting nuke on channel {}".format(blue, clear, channel)) | |
| try: | |
| messages = await channel.history(limit=99999).flatten() | |
| await channel.delete_messages(messages) | |
| except: | |
| pass | |
| client.run(TOKEN) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please make a .env file and define your DISCORD_TOKEN and CHANNEL_ID in it.