turdbot/bot/cogs/counting.py

38 lines
1.2 KiB
Python
Raw Normal View History

2024-03-12 13:14:01 -06:00
from discord.ext import bridge, commands
2024-06-12 19:21:51 -06:00
from bin.storage import storage
2023-12-04 13:51:43 -07:00
2024-03-12 13:14:01 -06:00
class Counting(commands.Cog):
def __init__(self, bot):
self.bot = bot
2023-12-04 13:51:43 -07:00
2024-03-12 13:14:01 -06:00
@commands.Cog.listener()
async def on_message(self, message):
db = storage(message.guild.id, self.bot.db).db
2024-03-12 15:59:59 -06:00
count = int(db('counting', 'count') or 0)
2024-03-12 13:14:01 -06:00
if message.author.bot or message.channel.id != db('counting', 'channel') or not message.content.isdigit():
return
elif message.author.id == db('counting', 'user'):
await message.reply(f"you done fucked up there chief, you cant count twice")
elif str(count+1) != message.content:
await message.reply(f"you done fucked up there chief, count was {count}")
else:
db('counting', 'count', count+1)
db('counting', 'user', message.author.id)
await message.add_reaction('')
@bridge.bridge_command()
async def channel(self, ctx):
db = storage(ctx.guild.id, self.bot.db).db
db('counting', 'channel', ctx.channel.id)
2024-03-12 15:59:59 -06:00
await ctx.send(f"counting channel set to {db('counting', 'channel')}")
2024-03-12 13:14:01 -06:00
2023-12-04 13:51:43 -07:00
def setup(bot):
bot.add_cog(Counting(bot))