Skip to content

Instantly share code, notes, and snippets.

@FWidm
Created September 2, 2020 19:27
Show Gist options
  • Save FWidm/e6e2195b2c8e088c18e1b9521cf40f8e to your computer and use it in GitHub Desktop.
Save FWidm/e6e2195b2c8e088c18e1b9521cf40f8e to your computer and use it in GitHub Desktop.
quick discord user "client" to roll in group chats during video calls
from random import randint
import discord
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
def roll(author, roll_message):
_, roll = roll_message.split()
rolling = []
try:
for x in range(int(roll.split('d')[0])):
rolling.append(randint(1, int(roll.split('d')[1])))
except Exception as err:
return f'I got bungled @_@ \n Error: {err}'
if len(rolling) > 1:
return f'>> @here **{author}** rolled **{" ".join(str(x) for x in rolling)}** | total: **{sum(rolling)}**'
else:
return f'>> @here **{author}** rolled **{" ".join(str(x) for x in rolling)}**'
@client.event
async def on_message(message):
if message.content.startswith('!roll'):
await message.channel.send(roll(message.author, message.content))
token = "your_token"
client.run(token, bot=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment