Skip to content

Commit

Permalink
updated main function to be asynchronoux (whatever that means)
Browse files Browse the repository at this point in the history
  • Loading branch information
Soulsender committed Aug 26, 2022
1 parent bbcda47 commit 6c8281f
Showing 1 changed file with 68 additions and 62 deletions.
130 changes: 68 additions & 62 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,80 +3,86 @@
from colorama import Fore
from discord.ext import commands
from dotenv import load_dotenv
import asyncio

load_dotenv()

intents = discord.Intents.default()
intents.message_content = True
client = commands.Bot(command_prefix="*", activity = discord.Game(name="I'm in fucking alpha don't expect much"), intents=intents)
client = commands.Bot(command_prefix="*", activity=discord.Game(name="I'm in fucking alpha don't expect much"),
intents=intents)
client.remove_command('help')

async def main():
async with client:

@client.command()
async def load(ctx, extension):
client.load_extension('cogs.{extension}')

@client.command()
async def unload(ctx, extension):
client.unload_extension('cogs.{extension}')

for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
client.load_extension(f'cogs.{filename[:-3]}')

@client.event
async def on_ready():
# init sequence, only print statements allowed
print("===== BOT INITILIZATION =====")
print(Fore.GREEN, '{0.user} standing by'.format(client), Fore.RESET)
print("===== SERVERS LOADED =====")
print(Fore.BLUE, '\n'.join(guild.name for guild in client.guilds), Fore.RESET)
print("===== MODULES LOADED =====", Fore.YELLOW)

@client.command()
async def sourcehelp(ctx):
embed = discord.Embed(title="__Source Code__", color=0x4287f5)
embed.add_field(name="Source code available on github", value="https://github.com/Soulsender/Earth-Invader", inline=False)
await ctx.send(embed=embed)

# cryptography help menu
@client.command()
async def help(ctx):
embed = discord.Embed(title="Codex Bot", color=0x2b2a2a)
embed.url = 'https://github.com/Soulsender/Codex-Bot'
embed.set_author(name='Soulsender#3162', url='https://soulsender.github.io')
embed.description = 'Basic Cryptography Commands'

embed.add_field(name="Base64", value="`b64 {encode/e & decode/d} {\"string\"}`\n"
"Encoding and decoding from base64.", inline=False)
embed.add_field(name="133T 5P34K", value="`leet {encode/e & decode/d} {\"string\"}`\n"
"Encoding and decoding from 133T 5P34K (Leet Speak).", inline=False)
embed.add_field(name="Hex", value="`hex {encode/e & decode/d} {\"string\"}`\n"
"Encoding and decoding from Hex.", inline=False)
embed.add_field(name="Caesar Cipher", value="`cc {encode/e & decode/d} {\"string\"} {key 1}`\n"
"Encoding and decoding with Caesar Cipher. *Requires a Key as an integer.*", inline=False)
embed.add_field(name="Rot47", value="`r47 {encode/e & decode/d} {\"string\"}`\n"
async def load_extensions():
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
# cut off the .py from the file name
await client.load_extension(f"cogs.{filename[:-3]}")

@client.event
async def on_ready():
# init sequence, only print statements allowed
print("===== BOT INITILIZATION =====")
print(Fore.GREEN, '{0.user} standing by'.format(client), Fore.RESET)
print("===== SERVERS LOADED =====")
print(Fore.BLUE, '\n'.join(guild.name for guild in client.guilds), Fore.RESET)
print("===== MODULES LOADED =====", Fore.YELLOW)


@client.command()
async def sourcehelp(ctx):
embed = discord.Embed(title="__Source Code__", color=0x4287f5)
embed.add_field(name="Source code available on github", value="https://github.com/Soulsender/Earth-Invader",
inline=False)
await ctx.send(embed=embed)


# cryptography help menu
@client.command()
async def help(ctx):
embed = discord.Embed(title="Codex Bot", color=0x2b2a2a)
embed.url = 'https://github.com/Soulsender/Codex-Bot'
embed.set_author(name='Soulsender#3162', url='https://soulsender.github.io')
embed.description = 'Basic Cryptography Commands'

embed.add_field(name="Base64", value="`b64 {encode/e & decode/d} {\"string\"}`\n"
"Encoding and decoding from base64.", inline=False)
embed.add_field(name="133T 5P34K", value="`leet {encode/e & decode/d} {\"string\"}`\n"
"Encoding and decoding from 133T 5P34K (Leet Speak).", inline=False)
embed.add_field(name="Hex", value="`hex {encode/e & decode/d} {\"string\"}`\n"
"Encoding and decoding from Hex.", inline=False)
embed.add_field(name="Caesar Cipher", value="`cc {encode/e & decode/d} {\"string\"} {key 1}`\n"
"Encoding and decoding with Caesar Cipher. *Requires a Key as an integer.*",
inline=False)
embed.add_field(name="Rot47", value="`r47 {encode/e & decode/d} {\"string\"}`\n"
"Encoding and decoding with Rotation 47.", inline=False)
embed.add_field(name="Rot13", value="`r13 {encode/e & decode/d} {\"string\"}`\n"
embed.add_field(name="Rot13", value="`r13 {encode/e & decode/d} {\"string\"}`\n"
"Encoding and decoding with Rotation 13.", inline=False)
embed.add_field(name="Binary", value="`bin {encode/e & decode/d} {\"string\"}`\n"
"Encoding and decoding with binary.", inline=False)
embed.add_field(name="Binary", value="`bin {encode/e & decode/d} {\"string\"}`\n"
"Encoding and decoding with binary.", inline=False)

embed.set_footer(text='Created by Soulsender. See the wiki for documentation.')
await ctx.send(embed=embed)


embed.set_footer(text='Created by Soulsender. See the wiki for documentation.')
await ctx.send(embed=embed)
# mimic
@client.command()
@commands.has_role('Bot Admin') # Checks for Administrator rank.
async def m(ctx, *, question):
await ctx.message.delete()
await ctx.send(f'{question}')


# mimic
@client.command()
@commands.has_role('Bot Admin') # Checks for Administrator rank.
async def m(ctx, *, question):
await ctx.message.delete()
await ctx.send(f'{question}')
@client.command()
async def servers(ctx):
servers = list(client.guilds)
await ctx.send(f"Connected on {str(len(servers))} servers:")
await ctx.send('\n'.join(guild.name for guild in client.guilds))

@client.command()
async def servers(ctx):
servers = list(client.guilds)
await ctx.send(f"Connected on {str(len(servers))} servers:")
await ctx.send('\n'.join(guild.name for guild in client.guilds))
await load_extensions()
await client.start(str(os.getenv('TOKEN')))

client.run(str(os.getenv('TOKEN')))
asyncio.run(main())

0 comments on commit 6c8281f

Please sign in to comment.