Skip to content

Commit

Permalink
revamp dumb code 🚑
Browse files Browse the repository at this point in the history
revamped code that doesn't make sense...
  • Loading branch information
core-hacked committed Dec 16, 2021
1 parent f90e1f8 commit af85325
Showing 1 changed file with 23 additions and 36 deletions.
59 changes: 23 additions & 36 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import sys
import argparse

prefix = str("#DEL") #change this to anything you want so when u type it in the channel it'll delete, or specify it as an argument with --prefix
# Set your defaults below, or specify with the respective arguments
prefix = str("#DEL")
token = str("")
heartbeat = int(86400)
serverpurge =str("#PS") #change this to anything you want so when u type it in the channel it'll delete, or specify it as an argument with --serverpurge
serverpurge =str("#PS")

class MyClient(discord.Client):
async def on_message(self, message):
Expand All @@ -23,63 +24,49 @@ async def on_message(self, message):
print(channel)
try:
async for mss in channel.history(limit=None):
#fetch all message, you might want to purge channel by channel to speedup if the server is old and big
# fetch all message, you might want to purge channel by channel to speed up if the server is old and big
if(mss.author==self.user):
print(mss.content)
try:
await mss.delete()
except:
print("Can't delete!\n")#this shouldn't happen unless you call purge multiple time
print("Can't delete!\n") # this shouldn't happen unless you call purge multiple time
except:
print("Can't read history!\n")

#alternatively, remove everything until client=MyClient.. and set your token and prefix at the top.

parser = argparse.ArgumentParser(description='')
parser.add_argument('-t','--token', dest='token', type=str, help='Token to use with message purger')
parser.add_argument('-p','--prefix', dest='prefix', type=str, help='Prefix to use with message purger')
parser.add_argument('-s','--serverpurge', dest='serverpurge', type=str, help='Specify a prefix to use for Server Purge')
parser.add_argument('-b','--heartbeat', dest='heartbeat', type=int, help='Heartbeat timeout to use')
args = parser.parse_args()

if args.serverpurge is not None:
serverpurge = args.serverpurge
if args.token is not None:
token = args.token
if args.prefix is not None:
prefix = args.prefix
if args.heartbeat is not None:
heartbeat = args.heartbeat
else:
token = input("Please input a Token: ")
prefix = input("Please input a prefix (leave blank for the default '#DEL'): ")
heartbeat = input("Please input a heartbeat timeout (leave blank for the default 86400): ")
serverpurge = input("Please input a server purge prefix (leave blank for the default '#PS'): ")
if prefix is None:
prefix="#DEL"
if heartbeat is None:
heartbeat = 86400
if serverpurge is None:
serverpurge = "#PS"
token = args.token
prefix = args.prefix
serverpurge = args.serverpurge
heartbeat = args.heartbeat

if token is not None:
token = args.token
else:
if args.token is not None:
token = args.token
if args.prefix is not None:
prefix = args.prefix
if args.heartbeat is not None:
heartbeat = args.heartbeat
else:
token = input("Please input a Token: ")
prefix = input("Please input a prefix (leave blank for the default '#DEL'): ")
heartbeat = input("Please input a heartbeat timeout (leave blank for the default 86400): ")
serverpurge = input("Please input a server purge prefix (leave blank for the default '#PS'): ")
token = input("Please input a Token: ")
prefix = input("Please input a prefix (leave blank for the default '#DEL'): ")
heartbeat = input("Please input a heartbeat timeout (leave blank for the default 86400): ")
serverpurge = input("Please input a server purge prefix (leave blank for the default '#PS'): ")
if prefix is None:
prefix="#DEL"
if heartbeat is None:
heartbeat = 86400
if serverpurge is None:
serverpurge = "#PS"

if prefix is None:
prefix = "#DEL"
if serverpurge is None:
serverpurge = "#PS"
if heartbeat is None:
heartbeat = 86400


client=MyClient(heartbeat_timeout=heartbeat, guild_subscriptions=False)
client.run(token, bot=False)

0 comments on commit af85325

Please sign in to comment.