Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- from discord.ext import commands
- import asyncio
- import pickle
- import random
- import math
- bot = commands.Bot(command_prefix='!')
- class Data:
- users = []
- stats = [[]]
- @bot.command()
- async def resetstats(ctx):
- if ctx.message.author == "214358195060080640":
- i()
- def x():
- with open("users.pickle", 'rb') as f:
- data = pickle.load(f)
- f.close()
- return data
- def i():
- data = Data
- with open("users.pickle", "wb") as f:
- pickle.dump(data, f)
- f.close()
- @bot.command()
- async def profilesetup(ctx):
- username = str(ctx.message.author.id)
- with open("users.pickle", "rb") as f:
- data = pickle.load(f)
- f.close()
- if (username in data.users):
- await ctx.send("Attempting to reroll your stats is cheating!")
- return
- else:
- position = len(data.users)
- data.users.append(username)
- stats = []
- for i in range(0, 5):
- stats.append(roll4d6take3high())
- data.stats.append(stats)
- await ctx.send("```\n"
- "User: %s\n"
- "Strength = %d (%d)\n"
- "Agility = %d (%d)\n"
- "Accuracy = %d (%d)\n"
- "Perception = %d (%d)\n"
- "Stealth = %d (%d)\n"
- "```" % (ctx.message.author,
- addList(stats[0]), math.floor((addList(stats[0]) - 10) / 2),
- addList(stats[1]), math.floor((addList(stats[1]) - 10) / 2),
- addList(stats[2]), math.floor((addList(stats[2]) - 10) / 2),
- addList(stats[3]), math.floor((addList(stats[3]) - 10) / 2),
- addList(stats[4]), math.floor((addList(stats[4]) - 10) / 2)))
- with open("user.pickle", "wb") as f:
- pickle.dump(data, f)
- f.close()
- def addList(list):
- tot = 0
- for i in list:
- tot += i
- return tot
- def roll4d6take3high():
- rolls = [random.randrange(1, 6) for x in range(4)]
- lowest = 7
- lpos = 0
- for i in range(0, len(rolls) - 1):
- if (rolls[i] < lowest):
- lowest = i + 0
- lpos = i
- rolls.pop()
- return rolls
- bot.run('token')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement