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):
|
2024-06-19 22:22:21 -06:00
|
|
|
store = storage(message.guild.id, self.bot.db).store
|
|
|
|
|
count = int(await store('counting', 'count') or 0)
|
2024-03-12 13:14:01 -06:00
|
|
|
|
2024-06-19 22:22:21 -06:00
|
|
|
if message.author.bot or message.channel.id != await store('counting', 'channel') or not message.content.isdigit():
|
2024-03-12 13:14:01 -06:00
|
|
|
return
|
|
|
|
|
|
2024-06-19 22:22:21 -06:00
|
|
|
elif message.author.id == await store('counting', 'user'):
|
2024-03-12 13:14:01 -06:00
|
|
|
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:
|
2024-06-19 22:22:21 -06:00
|
|
|
await store('counting', 'count', count+1)
|
|
|
|
|
await store('counting', 'user', message.author.id)
|
2024-03-12 13:14:01 -06:00
|
|
|
await message.add_reaction('✅')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bridge.bridge_command()
|
|
|
|
|
async def channel(self, ctx):
|
2024-06-19 22:22:21 -06:00
|
|
|
store = storage(ctx.guild.id, self.bot.db).store
|
|
|
|
|
await store('counting', 'channel', ctx.channel.id)
|
2024-06-22 19:32:58 -06:00
|
|
|
await ctx.respond(f"counting channel set to {await store('counting', 'channel')}")
|
2024-06-12 21:33:27 -06:00
|
|
|
|
|
|
|
|
@bridge.bridge_command()
|
2024-06-22 19:32:58 -06:00
|
|
|
async def setcount(self, ctx, count:int):
|
|
|
|
|
store = storage(ctx.guild.id, self.bot.db).store
|
|
|
|
|
await store('counting', 'count', count)
|
|
|
|
|
await ctx.respond(f"count set to {count}")
|
2024-03-12 13:14:01 -06:00
|
|
|
|
|
|
|
|
|
2023-12-04 13:51:43 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def setup(bot):
|
|
|
|
|
bot.add_cog(Counting(bot))
|