Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions cogs/_Example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import utils
from discord.ext import commands as skySB


class Example(skySB.Cog):
def __init__(self, bot) -> None:
self.bot = bot

@skySB.command(description='hi')
async def example(self, ctx) -> None:
await utils.answer(ctx, 'Hello!')


async def setup(bot) -> None:
await bot.add_cog(Example(bot))
await bot.add_cog(Example(bot))
28 changes: 16 additions & 12 deletions cogs/skyeval.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# ______ __ __ __ __ ______ ______
# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \
# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __<
# ______ __ __ __ __ ______ ______
# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \
# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __<
# \/\_____\ \ \_\ \_\ \/\_____\ \/\_____\ \ \_____\
# \/_____/ \/_/\/_/ \/_____/ \/_____/ \/_____/
#
#
# AGPL-3.0 license

import ast
import utils

from discord.ext import commands as skySB


def insert_returns(body):
if isinstance(body[-1], ast.Expr):
body[-1] = ast.Return(body[-1].value)
Expand All @@ -21,6 +22,7 @@ def insert_returns(body):
if isinstance(body[-1], ast.With):
insert_returns(body[-1].body)


async def execute_python_code(code, env={}):
try:
fn_name = "_eval_expr"
Expand All @@ -35,11 +37,12 @@ async def execute_python_code(code, env={}):
except Exception as error:
return error


class Eval(skySB.Cog):
def __init__(self, bot):
self.bot = bot
self.langpack = utils.Langs.getcurrent()['eval']

@skySB.command(
aliases=["eval", "py3", "python", "py"],
description=utils.Langs.getcurrent()['eval']['e']['description'],
Expand All @@ -49,7 +52,7 @@ async def e(self, ctx, *, code: str = None) -> None:
if code:
if code.startswith("```") and code.endswith("```"):
code = "\n".join(code.split("\n")[1:])[:-3]

result = await execute_python_code(
code,
{
Expand All @@ -66,20 +69,21 @@ async def e(self, ctx, *, code: str = None) -> None:
}
)
if getattr(result, 'stringify', ''):
try:
result = str(result.stringify())
except:
pass
try:
result = str(result.stringify())
except:
pass

await utils.answer(
ctx,
f"{self.langpack['e']['code']}"
f"```py\n{code}\n```\n"
f"{self.langpack['e']['result']}"
f"```py\n{result}\n```"
)
)
else:
await utils.answer(ctx, utils.Langs.getcurrent()['argRequired'].format('code'))


async def setup(bot) -> None:
await bot.add_cog(Eval(bot))
await bot.add_cog(Eval(bot))
30 changes: 16 additions & 14 deletions cogs/skyfun.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# ______ __ __ __ __ ______ ______
# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \
# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __<
# ______ __ __ __ __ ______ ______
# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \
# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __<
# \/\_____\ \ \_\ \_\ \/\_____\ \/\_____\ \ \_____\
# \/_____/ \/_/\/_/ \/_____/ \/_____/ \/_____/
#
#
# AGPL-3.0 license

import random
Expand All @@ -13,11 +13,12 @@
from discord.ext import commands as skySB
import utils


class Fun(skySB.Cog):
def __init__(self, bot):
self.bot = bot
self.langpack = utils.Langs.getcurrent()['fun']

@skySB.command(
description=utils.Langs.getcurrent()['fun']['dick']['description']
)
Expand All @@ -26,10 +27,10 @@ async def dick(self, ctx, user: discord.User = None):
mention = user.mention
else:
mention = self.bot.user

size = random.randint(1, 1000)
await utils.answer(
ctx,
ctx,
self.langpack['dick']['text'].format(mention, size))

@skySB.command(
Expand All @@ -40,12 +41,12 @@ async def iq(self, ctx, user: discord.User = None):
mention = user.mention
else:
mention = self.bot.user

iq = random.randint(1, 1000)
await utils.answer(
ctx,
ctx,
self.langpack['iq']['text'].format(mention, iq))

@skySB.command(
description=utils.Langs.getcurrent()['fun']['gay']['description']
)
Expand All @@ -54,11 +55,12 @@ async def gay(self, ctx, user: discord.User = None):
mention = user.mention
else:
mention = self.bot.user

percent = random.randint(0, 101)
await utils.answer(
ctx,
ctx,
self.langpack['gay']['text'].format(mention, percent))



async def setup(bot):
await bot.add_cog(Fun(bot))
await bot.add_cog(Fun(bot))
28 changes: 16 additions & 12 deletions cogs/skyhelp.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,40 @@
# ______ __ __ __ __ ______ ______
# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \
# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __<
# ______ __ __ __ __ ______ ______
# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \
# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __<
# \/\_____\ \ \_\ \_\ \/\_____\ \/\_____\ \ \_____\
# \/_____/ \/_/\/_/ \/_____/ \/_____/ \/_____/
#
#
# AGPL-3.0 license

import utils

from discord.ext import commands as skySB


class Help(skySB.Cog):
def __init__(self, bot):
self.bot = bot
self.langpack = utils.Langs.getcurrent()['help']

@skySB.command(
aliases=["h", "commands"],
description=utils.Langs.getcurrent()['help']['help']['description']
)
async def help(self, ctx, cmd: str = None):
msg = ''
msg += self.langpack['help']['title']
msg += self.langpack['help']['prefix'].format(utils.config.get('prefix'))

msg += self.langpack['help']['prefix'].format(
utils.config.get('prefix'))

for cog in self.bot.cogs:
cog_commands = self.bot.get_cog(cog).get_commands()

for command in cog_commands:
msg += self.langpack['help']['cmdformat'].format(command.name, command.description)

msg += self.langpack['help']['cmdformat'].format(
command.name, command.description)

await utils.answer(ctx, msg)



async def setup(bot):
await bot.add_cog(Help(bot))
await bot.add_cog(Help(bot))
21 changes: 12 additions & 9 deletions cogs/skyloader.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# ______ __ __ __ __ ______ ______
# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \
# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __<
# ______ __ __ __ __ ______ ______
# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \
# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __<
# \/\_____\ \ \_\ \_\ \/\_____\ \/\_____\ \ \_____\
# \/_____/ \/_/\/_/ \/_____/ \/_____/ \/_____/
#
#
# AGPL-3.0 license

import aiohttp
Expand All @@ -23,7 +23,8 @@ def __init__(self, bot):

@skySB.command(
aliases=["lm", "install", "le"],
description=utils.Langs.getcurrent()['loader']['loadExt']['description']
description=utils.Langs.getcurrent(
)['loader']['loadExt']['description']
)
async def loadExt(self, ctx, *, url: str = None):
await utils.answer(ctx, self.langpack['loadExt']['wait'].format(url))
Expand Down Expand Up @@ -62,7 +63,8 @@ async def loadExt(self, ctx, *, url: str = None):

@skySB.command(
aliases=["reload", "rl", "reloadcogs"],
description=utils.Langs.getcurrent()['loader']['reloadExt']['description']
description=utils.Langs.getcurrent(
)['loader']['reloadExt']['description']
)
async def reloadExt(self, ctx):
msg = ''
Expand All @@ -72,12 +74,13 @@ async def reloadExt(self, ctx):
extension = file[:-3]
try:
await self.bot.reload_extension(f"cogs.{extension}")
msg += self.langpack['reloadExt']['format'].format(extension)
msg += self.langpack['reloadExt']['format'].format(
extension)
except:
pass

await utils.answer(ctx, msg)


async def setup(bot):
await bot.add_cog(Loader(bot))
await bot.add_cog(Loader(bot))
13 changes: 7 additions & 6 deletions skySB.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# ______ __ __ __ __ ______ ______
# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \
# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __<
# ______ __ __ __ __ ______ ______
# /\ ___\ /\ \/ / /\ \_\ \ /\ ___\ /\ == \
# \ \___ \ \ \ _--. \ \____ \ \ \___ \ \ \ __<
# \/\_____\ \ \_\ \_\ \/\_____\ \/\_____\ \ \_____\
# \/_____/ \/_/\/_/ \/_____/ \/_____/ \/_____/
#
#
# AGPL-3.0 license

import os
Expand All @@ -15,6 +15,7 @@
print(motd)
logger.warning(f'status: {Fore.YELLOW}loading...{Style.RESET}')


@bot.event
async def on_ready():
os.system('clear')
Expand All @@ -23,7 +24,7 @@ async def on_ready():
logger.warning(f'connected: {Style.BOLD}{bot.user}{Style.RESET}')
logger.warning(f'prefix: {Style.BOLD}{config.get("prefix")}{Style.RESET}')
print("-" * 45)

for file in os.listdir(f"{os.path.realpath(os.path.dirname(__file__))}/cogs"):
if file.startswith("_"):
pass
Expand All @@ -36,4 +37,4 @@ async def on_ready():
logger.error(f'{extension}: {exception}')

while True:
bot.run(config.get('token'), log_handler=None)
bot.run(config.get('token'), log_handler=None)
Loading