diff --git a/bot/modules/__init__.py b/bot/modules/__init__.py index b1763cae..20630a1b 100644 --- a/bot/modules/__init__.py +++ b/bot/modules/__init__.py @@ -7,6 +7,7 @@ from .stats import * from .user_config import * from .workout import * from .todo import * +from .topgg import * from .reminders import * from .renting import * from .moderation import * diff --git a/bot/modules/topgg/__init__.py b/bot/modules/topgg/__init__.py new file mode 100644 index 00000000..d9785b83 --- /dev/null +++ b/bot/modules/topgg/__init__.py @@ -0,0 +1,3 @@ +from .module import module + +from . import topgg diff --git a/bot/modules/topgg/module.py b/bot/modules/topgg/module.py new file mode 100644 index 00000000..783d98a9 --- /dev/null +++ b/bot/modules/topgg/module.py @@ -0,0 +1,3 @@ +from LionModule import LionModule + +module = LionModule("Topgg") diff --git a/bot/modules/topgg/topgg.py b/bot/modules/topgg/topgg.py new file mode 100644 index 00000000..ad873a84 --- /dev/null +++ b/bot/modules/topgg/topgg.py @@ -0,0 +1,29 @@ +from meta import client +import discord +import topgg + +# client.log("test") + +import topgg + +# This example uses topggpy's webhook system. +client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("/dblwebhook", "nopassword123") + +# The port must be a number between 1024 and 49151. +client.topgg_webhook.run(5000) # this method can be awaited as well + + +@client.event +async def on_dbl_vote(data): + """An event that is called whenever someone votes for the bot on Top.gg.""" + client.log(f"Received a vote:\n{data}") + if data["type"] == "test": + # this is roughly equivalent to + # `return await on_dbl_test(data)` in this case + return client.dispatch("dbl_test", data) + + +@client.event +async def on_dbl_test(data): + """An event that is called whenever someone tests the webhook system for your bot on Top.gg.""" + client.log(f"Received a test vote:\n{data}") \ No newline at end of file