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
2 changes: 1 addition & 1 deletion src/achievement.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def achieve(bot: commands.Bot, message: discord.Message, achievement):
await bot.database.commit()
logging.info("Awarded achievement %s to %s", achievement, message.author.name)

def setup(bot):
async def setup(bot):
@bot.group(name="achievements", aliases=["ach", "achieve", "achievement"], brief="Achieve a wide variety of fun achievements!", help=f"""
Do things and get arbitrary achievements for them!
Note that due to reasons messages for achievements will not be shown except in opted-in servers, although achievements will be gained regardless.
Expand Down
4 changes: 2 additions & 2 deletions src/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,5 @@ async def random_choice(self, ctx, *choices):

await ctx.send("\n".join(map(lambda x: f"{x[0]} x{x[1]}", results)))

def setup(bot):
bot.add_cog(GeneralCommands(bot))
async def setup(bot):
await bot.add_cog(GeneralCommands(bot))
6 changes: 3 additions & 3 deletions src/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import util
import eventbus

def setup(bot):
async def setup(bot):
@bot.group(help="Debug/random messing around utilities. Owner-only.")
@commands.check(util.admin_check)
async def magic(ctx):
Expand Down Expand Up @@ -76,6 +76,6 @@ async def reload_config(ctx):
@magic.command(help="Reload extensions (all or the specified one).")
async def reload_ext(ctx, ext="all"):
if ext == "all":
for ext in util.extensions: bot.reload_extension(ext)
else: bot.reload_extension(ext)
for ext in util.extensions: await bot.reload_extension(ext)
else: await bot.reload_extension(ext)
await ctx.send("Done!")
2 changes: 1 addition & 1 deletion src/esoserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

role_transfer_lock = asyncio.Lock()

def setup(bot):
async def setup(bot):
@bot.listen()
async def on_message(message):
if message.guild and message.guild.id == util.config["esoserver"]["id"]:
Expand Down
2 changes: 1 addition & 1 deletion src/heavserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import metrics

def setup(bot):
async def setup(bot):
@bot.listen()
async def on_member_join(member):
if member.guild and member.guild.id == util.config["heavserver"]["id"]:
Expand Down
4 changes: 2 additions & 2 deletions src/irc_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async def on_bridge_message(channel_name, msg):
for line in lines:
conn.privmsg(channel_name, render_line(msg.author, line))
for at in msg.attachments:
conn.privmsg(channel_name, render_line(msg.author, f"-> {at.filename}: {at.proxy_url}"))
conn.privmsg(channel_name, render_line(msg.author, f"-> {at.filename}: {at.url}"))
else:
logging.warning("IRC channel %s not allowed", channel_name)

Expand All @@ -113,7 +113,7 @@ def disconnect(conn, event):
global unlisten
unlisten = eventbus.add_listener(util.config["irc"]["name"], on_bridge_message)

def setup(bot):
async def setup(bot):
asyncio.create_task(initialize())

def teardown(bot=None):
Expand Down
9 changes: 5 additions & 4 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@ def get_guild_count():
async def run_bot():
bot.database = await db.init(config["database"])
await eventbus.initial_load(bot.database)
for ext in util.extensions:
logging.info("Loaded %s", ext)
bot.load_extension(ext)
await bot.start(config["token"])
async with bot:
for ext in util.extensions:
logging.info("Loaded %s", ext)
await bot.load_extension(ext)
await bot.start(config["token"])

if __name__ == "__main__":
loop = asyncio.get_event_loop()
Expand Down
4 changes: 2 additions & 2 deletions src/reminders.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ async def reminder_loop(self):
self.reminder_queue.pop(0)
await self.fire_reminder(next_id)

def setup(bot):
async def setup(bot):
cog = Reminders(bot)
asyncio.create_task(cog.init_reminders())
bot.add_cog(cog)
await bot.add_cog(cog)

def teardown(bot):
bot.rloop_task.cancel()
4 changes: 2 additions & 2 deletions src/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@ def cog_unload(self):
if self.pool is not None:
self.pool.shutdown()

def setup(bot):
async def setup(bot):
cog = Search(bot)
bot.add_cog(cog)
await bot.add_cog(cog)
8 changes: 4 additions & 4 deletions src/telephone.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async def on_bridge_message(self, channel_id, msg: eventbus.Message):
channel = self.bot.get_channel(channel_id)
if channel:
webhook = self.webhooks.get(channel_id)
attachments_text = "\n".join(f"{at.filename}: {at.proxy_url}" for at in msg.attachments)
attachments_text = "\n".join(f"{at.filename}: {at.url}" for at in msg.attachments)
async def send_raw(text):
if webhook:
try:
Expand Down Expand Up @@ -132,7 +132,7 @@ async def send_to_bridge(self, msg):
reply = (eventbus.AuthorInfo(replying_to.author.name, replying_to.author.id, str(replying_to.author.display_avatar.url), replying_to.author.bot), parse_formatting(self.bot, replying_to.content))
else:
reply = (None, None)
msg = eventbus.Message(eventbus.AuthorInfo(msg.author.name, msg.author.id, str(msg.author.display_avatar.url), msg.author.bot),
msg = eventbus.Message(eventbus.AuthorInfo(msg.author.global_name or msg.author.name, msg.author.id, str(msg.author.display_avatar.url), msg.author.bot),
parse_formatting(self.bot, msg.content), ("discord", channel_id), msg.id, [ at for at in msg.attachments if not at.is_spoiler() ], reply=reply)
await eventbus.push(msg)

Expand Down Expand Up @@ -427,7 +427,7 @@ def node_name(x):
finally:
os.unlink(tmppath)

def setup(bot):
async def setup(bot):
cog = Telephone(bot)
bot.add_cog(cog)
await bot.add_cog(cog)
asyncio.create_task(cog.initial_load_webhooks())
4 changes: 2 additions & 2 deletions src/userdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@ async def delete(self, ctx, *keys):
await self.bot.database.commit()
await ctx.send(f"**{key}** deleted")

def setup(bot):
bot.add_cog(Userdata(bot))
async def setup(bot):
await bot.add_cog(Userdata(bot))
2 changes: 1 addition & 1 deletion src/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ async def get_asset(bot: commands.Bot, identifier):
return x["url"]
file = discord.File(os.path.join("./assets", identifier), filename=safe_ident)
message = await (bot.get_channel(config["image_upload_channel"])).send(identifier, file=file)
url = message.attachments[0].proxy_url
url = message.attachments[0].url
await bot.database.execute("INSERT INTO assets VALUES (?, ?)", (safe_ident, url))
return url

Expand Down
2 changes: 1 addition & 1 deletion src/voice.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async def start(self):
def read(self): return next(self.packets, b"")
def is_opus(self): return True

def setup(bot):
async def setup(bot):
# experimental, thus limit to me only
@bot.group()
@commands.check(util.admin_check)
Expand Down