Skip to content

Commit

Permalink
Merge pull request #12 from notsniped/debloat-source-code
Browse files Browse the repository at this point in the history
Debloat main code
  • Loading branch information
notsniped authored Aug 11, 2022
2 parents 5b814bc + d13751f commit 2d47968
Showing 1 changed file with 24 additions and 40 deletions.
64 changes: 24 additions & 40 deletions Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,35 @@

# USER CONFIGURATION

prefix = '-' # Default prefix is -, you can replace it with your preferred prefix
owner = 'EMPTY_USERNAME#0000' # Replace 'EMPTY_USERNAME#0000' with your Discord username
bot_token = '' # Add the bot token in this variable. For more info check README.md
prefix = "-" # Default prefix is -, you can replace it with your preferred prefix
owner = "EMPTY_USERNAME#0000" # Replace 'EMPTY_USERNAME#0000' with your Discord username
bot_token = "" # Add the bot token in this variable. For more info check README.md

# USER CONFIGURATION END

intents = discord.Intents.all()
botVer = 'v1.2.1'
if os.name == 'nt':
os.system('cls')
else:
os.system('clear')
if os.name == 'nt': os.system('cls')
else: os.system('clear')
client = commands.Bot(command_prefix=str(prefix), intents=intents) # READ COMMENT AT LINE 13 FOR MORE INFO
slash = SlashCommand(client, sync_commands=True)
global startTime
startTime = time.time()
client.remove_command('help')
homedir = os.getcwd()
config:dict = {}
config = {}

if os.name == 'nt':
with open(f'{homedir}\\config.json', 'r') as f:
config = json.load(f)
else:
with open(f'{homedir}/config.json', 'r') as f:
config = json.load(f)
if os.name == 'nt':
with open(f'{homedir}\\config.json', 'r') as f: config = json.load(f)
else:
with open(f'{homedir}/config.json', 'r') as f: config = json.load(f)

snipe_log:bool = config[str("config")][str("logs")]["snipe"]
editsnipe_log:bool = config[str("config")][str("logs")]["editsnipe"]

def randColor():
return discord.Color.random()

@client.command()
async def help(ctx):
e = discord.Embed(title='Command Help', description=f'Prefix: `{prefix}`\n\n`{str(prefix)}snipe`: See the most recently deleted message in this channel.\n`{str(prefix)}editsnipe`: See the most recently edited message in this channel.', color=randColor())
e = discord.Embed(title='Command Help', description=f'Prefix: `{prefix}`\n\n`{str(prefix)}snipe`: See the most recently deleted message in this channel.\n`{str(prefix)}editsnipe`: See the most recently edited message in this channel.', color=discord.Color.random())
await ctx.send(embed=e)

@client.event
Expand All @@ -66,14 +59,11 @@ async def on_ready():
@client.event
async def on_message_delete(message):
if not message.author.bot:
guild = client.guilds[0]
channel = message.channel
snipe_message_author[message.channel.id] = message.author
snipe_message_content[message.channel.id] = message.content
if bool(snipe_log) == True:
print(f"Message deleted in #{channel.name} ({guild.name}):\n Message content: {message.content}")
else:
pass
if bool(snipe_log): print(f"Message deleted in #{channel} ({message.guild}):\n Message content: {message.content}")
else: pass

@client.event
async def on_message_edit(message_before, message_after):
Expand All @@ -83,30 +73,26 @@ async def on_message_edit(message_before, message_after):
channel = message_before.channel
editsnipe_message_before_content[channel.id] = message_before.content
editsnipe_message_after_content[channel.id] = message_after.content
if bool(editsnipe_log) == True:
print(f"Message edited in #{channel.name} ({guild.name}):\n Old message: {message_before.content}\n New message: {message_after.content}")
else:
pass
if bool(editsnipe_log): print(f"Message edited in #{channel} ({message_before.guild}):\n Old message: {message_before.content}\n New message: {message_after.content}")
else: pass

@client.command()
async def snipe(ctx):
channel = ctx.channel
try:
em = discord.Embed(name=f"Last deleted message in #{channel.name}", description=snipe_message_content[channel.id], color=randColor())
em = discord.Embed(name=f"Last deleted message in #{channel.name}", description=snipe_message_content[channel.id], color=discord.Color.random())
em.set_footer(text=f"This message was sent by {snipe_message_author[channel.id]}")
await ctx.send(embed=em)
except KeyError:
await ctx.send(f"There are no recently deleted messages in <#{channel.id}>")
except KeyError: await ctx.send(f"There are no recently deleted messages in <#{channel.id}>")

@client.command()
async def editsnipe(ctx):
channel = ctx.channel
try:
em = discord.Embed(description=f'**Message before**:```{editsnipe_message_before_content[ctx.channel.id]}```\n**Message after**:```{editsnipe_message_after_content[ctx.channel.id]}```', color=randColor())
em = discord.Embed(description=f'**Message before**:```{editsnipe_message_before_content[ctx.channel.id]}```\n**Message after**:```{editsnipe_message_after_content[ctx.channel.id]}```', color=discord.Color.random())
em.set_footer(text=f'This message was edited by {editsnipe_message_author[channel.id]}')
await ctx.send(embed=em)
except KeyError:
await ctx.reply(f'There are no recently edited messages in <#{ctx.channel.id}>')
except KeyError: await ctx.reply(f'There are no recently edited messages in <#{ctx.channel.id}>')

@slash.slash(
name="snipe",
Expand All @@ -115,11 +101,10 @@ async def editsnipe(ctx):
async def snipe(ctx: SlashContext):
channel = ctx.channel
try:
em = discord.Embed(name=f"Last deleted message in #{channel.name}", description=snipe_message_content[channel.id], color=randColor())
em = discord.Embed(name=f"Last deleted message in #{channel.name}", description=snipe_message_content[channel.id], color=discord.Color.random())
em.set_footer(text=f"This message was sent by {snipe_message_author[channel.id]}")
await ctx.send(embed=em)
except KeyError:
await ctx.send(f"There are no recently deleted messages in <#{channel.id}>")
except KeyError: await ctx.send(f"There are no recently deleted messages in <#{channel.id}>")

@slash.slash(
name="editsnipe",
Expand All @@ -128,10 +113,9 @@ async def snipe(ctx: SlashContext):
async def editsnipe(ctx: SlashContext):
channel = ctx.channel
try:
em = discord.Embed(description=f'**Message before**:```{editsnipe_message_before_content[ctx.channel.id]}```\n**Message after**:```{editsnipe_message_after_content[ctx.channel.id]}```', color=randColor())
em = discord.Embed(description=f'**Message before**:```{editsnipe_message_before_content[ctx.channel.id]}```\n**Message after**:```{editsnipe_message_after_content[ctx.channel.id]}```', color=discord.Color.random())
em.set_footer(text=f'This message was edited by {editsnipe_message_author[channel.id]}')
await ctx.send(embed=em)
except KeyError:
await ctx.reply(f'There are no recently edited messages in <#{ctx.channel.id}>')
except KeyError: await ctx.reply(f'There are no recently edited messages in <#{ctx.channel.id}>')

client.run(str(bot_token))
client.run(bot_token)

0 comments on commit 2d47968

Please sign in to comment.