Skip to content

Commit

Permalink
Bump to discord.py 2.0a
Browse files Browse the repository at this point in the history
  • Loading branch information
DXsmiley committed Aug 16, 2022
1 parent 2112a34 commit 112cbe3
Show file tree
Hide file tree
Showing 20 changed files with 49 additions and 66 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ htmlcov
.pytest_cache
.vscode/
Pipfile.lock
.venv
27 changes: 0 additions & 27 deletions Pipfile

This file was deleted.

25 changes: 4 additions & 21 deletions mathbot/bot.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
#!/usr/bin/env python3
# encoding: utf-8

import os
import sys
import warnings
import logging
import asyncio
import re
import json
import typing
import traceback
import objgraph
import gc
import time

import termcolor
import discord
import discord.ext.commands
from discord.ext.commands.errors import *
from discord.ext.commands.errors import CommandNotFound, MissingRequiredArgument, TooManyArguments, BadArgument, NoPrivateMessage, MissingPermissions, DisabledCommand, CommandInvokeError

import core.blame
import core.keystore
Expand Down Expand Up @@ -53,11 +45,7 @@ def __init__(self, parameters):
print(f'Starting bot shards {shard_ids} ({shard_count} total)')
super().__init__(
command_prefix=_determine_prefix,
pm_help=True,
shard_count=shard_count,
shard_ids=shard_ids,
max_messages=2000,
fetch_offline_members=False
intents=discord.Intents.default()
)
self.parameters = parameters
self.release = parameters.get('release')
Expand All @@ -68,8 +56,6 @@ def __init__(self, parameters):
self.closing_due_to_indeterminite_prefix = False
assert self.release in ['development', 'beta', 'release']
self.remove_command('help')
for i in _get_extensions(parameters):
self.load_extension(i)

def run(self):
super().run(self.parameters.get('token'))
Expand All @@ -78,11 +64,8 @@ async def on_shard_ready(self, shard_id):
print('on_shard_ready', shard_id)

async def on_ready(self):
print('on_ready')
self._connection.emoji = []
gc.collect()
objgraph.show_most_common_types()
# await self.leave_inactive_servers()
for i in _get_extensions(self.parameters):
await self.load_extension(i)

async def on_disconnect(self):
print('on_disconnect')
Expand Down
2 changes: 1 addition & 1 deletion mathbot/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async def wait_for_slot_in_gateway_queue():
except aiohttp.ClientConnectorError:
print('Could not find gateway queue to connect to')

asyncio.get_event_loop().run_until_complete(wait_for_slot_in_gateway_queue())
asyncio.run(wait_for_slot_in_gateway_queue())

parameters = retrieve_parameters()

Expand Down
6 changes: 3 additions & 3 deletions mathbot/modules/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import aiohttp
import datetime
import core.help
from discord.ext.commands import command, Cog
from discord.ext.commands import command, Cog, Bot
import codecs
from modules.reporter import report
from core.settings import command_allowed
Expand Down Expand Up @@ -107,5 +107,5 @@ def get_memory_usage():
return mem // (1024 * 1024)


def setup(bot):
bot.add_cog(AboutModule())
def setup(bot: Bot):
return bot.add_cog(AboutModule())
2 changes: 1 addition & 1 deletion mathbot/modules/blame.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ def error_response(text):

def setup(bot):
core.help.load_from_file('./help/blame.md')
bot.add_cog(BlameModule())
return bot.add_cog(BlameModule())
2 changes: 1 addition & 1 deletion mathbot/modules/calcmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,4 +548,4 @@ async def download_text(session: aiohttp.ClientSession, url: str) -> str:


def setup(bot):
bot.add_cog(CalculatorModule(bot))
return bot.add_cog(CalculatorModule(bot))
2 changes: 1 addition & 1 deletion mathbot/modules/dice.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ def gaussian_roll_single(self, dice, faces):
return int(random.gauss(mean, std))

def setup(bot):
bot.add_cog(DiceModule())
return bot.add_cog(DiceModule())
2 changes: 1 addition & 1 deletion mathbot/modules/echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ async def echo(self, context, *, text: str):


def setup(bot):
bot.add_cog(EchoModule(bot))
return bot.add_cog(EchoModule(bot))
2 changes: 1 addition & 1 deletion mathbot/modules/heartbeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ async def heartbeat(self, context):
await context.send('\n'.join(lines))

def setup(bot):
bot.add_cog(Heartbeat(bot))
return bot.add_cog(Heartbeat(bot))
2 changes: 1 addition & 1 deletion mathbot/modules/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ def _suggest_topics(self, typo):
return f"That help topic does not exist.\nMaybe you meant one of: {', '.join(map('`{}`'.format, suggestions))}?"

def setup(bot):
bot.add_cog(HelpModule())
return bot.add_cog(HelpModule())
2 changes: 1 addition & 1 deletion mathbot/modules/latex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,4 @@ def process_latex(latex, is_inline):


def setup(bot):
bot.add_cog(LatexModule(bot))
return bot.add_cog(LatexModule(bot))
2 changes: 1 addition & 1 deletion mathbot/modules/oeis.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ async def oeis(self, ctx, *, query=''):


def setup(bot):
bot.add_cog(OEIS())
return bot.add_cog(OEIS())
2 changes: 1 addition & 1 deletion mathbot/modules/purge.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ async def purge(self, ctx, number: int):
await asyncio.sleep(1)

def setup(bot):
bot.add_cog(PurgeModule())
return bot.add_cog(PurgeModule())
2 changes: 1 addition & 1 deletion mathbot/modules/reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ async def reboot(self, ctx):
])

def setup(bot):
bot.add_cog(Reboot())
return bot.add_cog(Reboot())
2 changes: 1 addition & 1 deletion mathbot/modules/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,4 @@ async def report_via_webhook_only(bot, string: str):


def setup(bot):
bot.add_cog(ReporterModule(bot))
return bot.add_cog(ReporterModule(bot))
2 changes: 1 addition & 1 deletion mathbot/modules/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,4 @@ async def setprefix(self, ctx, *, new_prefix):
await ctx.send(f'Bot prefix for this server has been changed to `{prefix}`.')

def setup(bot):
bot.add_cog(SettingsModule())
return bot.add_cog(SettingsModule())
2 changes: 1 addition & 1 deletion mathbot/modules/throws.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ async def throw(self, context):
raise Exception('I wonder what went wrong?')

def setup(bot):
bot.add_cog(ThrowsModule())
return bot.add_cog(ThrowsModule())
2 changes: 1 addition & 1 deletion mathbot/modules/wolfram.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,4 +540,4 @@ def cleanup_section_list(items):


def setup(bot):
bot.add_cog(WolframModule(bot))
return bot.add_cog(WolframModule(bot))
26 changes: 26 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
aiohttp==3.8.1
aioredis==1.2.0
aiosignal==1.2.0
async-timeout==4.0.2
attrs==21.4.0
cffi==1.15.0
chardet==3.0.4
charset-normalizer==2.1.0
colorama==0.4.4
discord.py @ git+https://github.com/Rapptz/discord.py.git@1a11c9eeee7a1ba0a427be4ba7d255007a32c3e2
frozenlist==1.3.1
graphviz==0.20
hiredis==2.0.0
idna==3.3
mpmath==1.2.1
multidict==4.7.6
objgraph==3.5.0
orjson==3.6.8
Pillow==9.1.0
psutil==5.9.0
pycparser==2.21
sympy==1.4
termcolor==1.1.0
websockets==8.1
xmltodict==0.12.0
yarl==1.5.1

0 comments on commit 112cbe3

Please sign in to comment.