44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
from discord.ext import bridge, commands
|
|
from bin.storage import storage
|
|
|
|
class Counting(commands.Cog):
|
|
def __init__(self, bot):
|
|
self.bot = bot
|
|
|
|
@commands.Cog.listener()
|
|
async def on_message(self, message):
|
|
store = storage(message.guild.id, self.bot.db).store
|
|
count = int(await store('counting', 'count') or 0)
|
|
|
|
if message.author.bot or message.channel.id != await store('counting', 'channel') or not message.content.isdigit():
|
|
return
|
|
|
|
elif message.author.id == await store('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:
|
|
await store('counting', 'count', count+1)
|
|
await store('counting', 'user', message.author.id)
|
|
await message.add_reaction('✅')
|
|
|
|
|
|
@bridge.bridge_command()
|
|
async def channel(self, ctx):
|
|
store = storage(ctx.guild.id, self.bot.db).store
|
|
await store('counting', 'channel', ctx.channel.id)
|
|
await ctx.respond(f"counting channel set to {await store('counting', 'channel')}")
|
|
|
|
@bridge.bridge_command()
|
|
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}")
|
|
|
|
|
|
|
|
|
|
def setup(bot):
|
|
bot.add_cog(Counting(bot)) |