├── README.md └── main.py /README.md: -------------------------------------------------------------------------------- 1 | # codegolf-discord 2 | a discord bot to make playing code golf with your friends fun 3 | 4 | In a light hearted fashion, my CS class and I decided to do code golf. I thought something like this would be cool, so literally rattled this off in about 5 mins before it started, and worked out pretty well. Also hence likely the occasional bug. 5 | 6 | [wikipedia article](https://en.wikipedia.org/wiki/Code_golf) about what codegolf is if you were wondering. 7 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import discord 2 | from discord.ext import commands 3 | 4 | client = discord.Client() 5 | client = commands.Bot(command_prefix='.') 6 | 7 | 8 | submissions = {} 9 | 10 | @client.event 11 | async def on_ready(): 12 | print ("online") 13 | 14 | @client.command() 15 | async def submit(ctx): 16 | submitee = ctx.message.author 17 | submission = ctx.message.content 18 | submissions[f'{submitee}'] = f'{submission}' 19 | await client.get_channel(728561287570915378).send(f'{submitee.mention} just submitted their submission :eyes: ') 20 | 21 | @client.command() 22 | async def show(): 23 | if submissions != {}: 24 | for value in submissions: 25 | await client.get_channel(728561287570915378).send(f'{value} submitted:\n{len(str(submissions[value])[8:])} chars\n\n```py\n{str(submissions[value])[8:]}```') 26 | else: 27 | await client.get_channel(728561287570915378).send('no submissions rn :slight_frown:') 28 | @client.command() 29 | async def clear(ctx): 30 | submissions.clear() 31 | await ctx.message.channel.send('cleared') 32 | 33 | client.run('') 34 | --------------------------------------------------------------------------------