🗃️ UserID's instead of display names

This commit is contained in:
Nikolaj Danger
2020-08-04 16:59:13 +02:00
parent 4bcc8cbf59
commit 2ea11eb51f
11 changed files with 201 additions and 111 deletions

View File

@ -10,7 +10,7 @@ import random
#import math
import os
from funcs import helloFunc, cap, imageFunc, logThis, findWikiPage, makeFiles, emojiToNumber, fiarReactionTest, deleteGame, stopServer, checkBalance, giveMoney, triviaCountPoints, triviaStart, triviaAnswer, blackjackShuffle, blackjackStart, blackjackPlayerDrawHand, blackjackContinue, blackjackFinish, blackjackHit, blackjackStand, blackjackDouble, blackjackSplit, parseFourInARow, fourInARowAI, spellFunc, monsterFunc, nameGen, tavernGen, movieFunc, roll_dice, parseChar, parseRoll, critRoll, parseDestiny, parseHex
from funcs import helloFunc, cap, imageFunc, logThis, findWikiPage, makeFiles, emojiToNumber, fiarReactionTest, deleteGame, stopServer, checkBalance, giveMoney, triviaCountPoints, triviaStart, triviaAnswer, blackjackShuffle, blackjackStart, blackjackPlayerDrawHand, blackjackContinue, blackjackFinish, blackjackHit, blackjackStand, blackjackDouble, blackjackSplit, parseFourInARow, fourInARowAI, spellFunc, monsterFunc, nameGen, tavernGen, movieFunc, roll_dice, parseChar, parseRoll, critRoll, parseDestiny, parseHex, addToDict
from gameLoops import fiar, blackjackLoop, runhex
@ -58,7 +58,7 @@ async def parseCommands(message,content):
# Stops the bot
elif content.startswith("stop"):
try:
if message.author.display_name == "Nikolaj":
if "#"+str(message.author.id) == "#266269899859427329":
await message.channel.send("Logging out...")
stopServer()
@ -220,7 +220,7 @@ async def parseCommands(message,content):
elif content.startswith("swroll"):
try:
command = cap(content.replace("swroll",""))
newMessage = parseRoll(message.author.display_name,command)
newMessage = parseRoll("#"+str(message.author.id),command)
messageList = newMessage.split("\n")
for messageItem in messageList:
await message.channel.send(messageItem)
@ -232,7 +232,7 @@ async def parseCommands(message,content):
elif content.startswith("swd"):
try:
command = content.replace("swd","")
newMessage = parseDestiny(message.author.display_name,command)
newMessage = parseDestiny("#"+str(message.author.id),command)
messageList = newMessage.split("\n")
for messageItem in messageList:
await message.channel.send(messageItem)
@ -266,7 +266,7 @@ async def parseCommands(message,content):
elif content.startswith("swchar") or content.startswith("sw"):
try:
command = string.capwords(content.replace("swchar","").replace("sw","").replace("+","+ ").replace("-","- ").replace(",",", "))
title, desc = parseChar(message.author.display_name,command)
title, desc = parseChar("#"+str(message.author.id),command)
if title != "":
em1 = discord.Embed(title = title, description = desc, colour=0xDEADBF)
await message.channel.send(embed = em1)
@ -323,7 +323,7 @@ async def parseCommands(message,content):
elif content.startswith("trivia "):
command = content.replace("trivia ","")
response = triviaAnswer(message.author.display_name.lower(),str(message.channel),command)
response = triviaAnswer("#"+str(message.author.id),str(message.channel),command)
if response.startswith("Locked in "):
await message.add_reaction("👍")
else:
@ -339,7 +339,7 @@ async def parseCommands(message,content):
# Checks your GwendoBucks balance
elif content.startswith("balance"):
try:
response = checkBalance(message.author.display_name.lower())
response = checkBalance("#"+str(message.author.id))
if response == 1:
new_message = message.author.display_name + " has " + str(response) + " GwendoBuck"
else:
@ -360,7 +360,7 @@ async def parseCommands(message,content):
logThis("Conversion error (error code 1221)",str(message.channel))
await message.channel.send("I didn't quite understand that (error code 1221)")
else:
response = giveMoney(message.author.display_name.lower(),commands[1],amount)
response = giveMoney("#"+str(message.author.id),commands[1],amount)
await message.channel.send(response)
else:
logThis("I didn't understand that (error code 1222)",str(message.channel))
@ -426,20 +426,20 @@ async def parseCommands(message,content):
logThis("I didn't understand that",str(message.channel))
response = "I didn't understand that"
else:
response = blackjackPlayerDrawHand(str(message.channel),message.author.display_name,amount)
response = blackjackPlayerDrawHand(str(message.channel),"#"+str(message.author.id),amount)
await message.channel.send(response)
# Hitting
elif content.startswith("blackjack hit"):
if content == "blackjack hit" or content == "blackjack hit ":
response = blackjackHit(str(message.channel),message.author.display_name)
response = blackjackHit(str(message.channel),"#"+str(message.author.id))
else:
commands = content.split(" ")
try:
handNumber = int(commands[2])
except:
handNumber = 0
response = blackjackHit(str(message.channel),message.author.display_name,handNumber)
response = blackjackHit(str(message.channel),"#"+str(message.author.id),handNumber)
if response.startswith("accept"):
await message.add_reaction("👍")
@ -458,14 +458,14 @@ async def parseCommands(message,content):
# Standing
elif content.startswith("blackjack stand"):
if content == "blackjack hit" or content == "blackjack hit ":
response = blackjackStand(str(message.channel),message.author.display_name)
response = blackjackStand(str(message.channel),"#"+str(message.author.id))
else:
commands = content.split(" ")
try:
handNumber = int(commands[2])
except:
handNumber = 0
response = blackjackStand(str(message.channel),message.author.display_name,handNumber)
response = blackjackStand(str(message.channel),"#"+str(message.author.id),handNumber)
if response.startswith("accept"):
await message.add_reaction("👍")
@ -487,7 +487,7 @@ async def parseCommands(message,content):
handNumber = int(commands[2])
except:
handNumber = 0
response, roundDone = blackjackDouble(str(message.channel),message.author.display_name,handNumber)
response, roundDone = blackjackDouble(str(message.channel),"#"+str(message.author.id),handNumber)
await message.channel.send(response)
@ -507,7 +507,7 @@ async def parseCommands(message,content):
handNumber = int(commands[2])
except:
handNumber = 0
response, roundDone = blackjackSplit(str(message.channel),message.author.display_name,handNumber)
response, roundDone = blackjackSplit(str(message.channel),"#"+str(message.author.id),handNumber)
await message.channel.send(response)
@ -521,7 +521,7 @@ async def parseCommands(message,content):
logThis("Something fucked up (error code 1320)")
# Returning current hi-lo value
elif content.startswith("blackjack hilo") and message.author.display_name == "Nikolaj":
elif content.startswith("blackjack hilo") and "#"+str(message.author.id) == "#266269899859427329":
if os.path.exists("resources/games/blackjackCards/"+str(message.channel)+".txt"):
with open("resources/games/hilo/"+str(message.channel)+".txt", "r") as f:
data = f.read()
@ -557,7 +557,7 @@ async def parseCommands(message,content):
elif content.startswith("fourinarow"):
try:
command = content.replace("fourinarow","")
await fiar(message.channel,command,message.author.display_name)
await fiar(message.channel,command,"#"+str(message.author.id))
except:
logThis("Something went wrong (error code 1400)")
@ -565,7 +565,7 @@ async def parseCommands(message,content):
elif content.startswith("hex"):
try:
command = content.replace("hex","")
await runhex(message.channel,command,message.author.display_name)
await runhex(message.channel,command,"#"+str(message.author.id))
except:
logThis("Something went wrong (error code 1500)")
@ -574,7 +574,6 @@ async def parseCommands(message,content):
logThis("That's not a command (error code 001)",str(message.channel))
await message.channel.send("That's not a command (error code 001)")
# Makes files if they don't exist yet
makeFiles()
@ -597,7 +596,8 @@ async def on_message(message):
try:
content = message.content
if content.startswith(commandPrefix):
logThis(message.author.display_name+" ran \""+content+"\"",str(message.channel))
logThis(message.author.display_name+" ("+"#"+str(message.author.id)+") ran \""+content+"\"",str(message.channel))
addToDict("#"+str(message.author.id),message.author.display_name)
await parseCommands(message,content.lower()[1:])
except:
logThis("Something fucked up (error code 000)")
@ -615,11 +615,11 @@ async def on_reaction_add(reaction,user):
message = reaction.message
channel = message.channel
logThis(user.display_name+" reacted to a message",str(channel))
fourInARowTheirTurn, piece = fiarReactionTest(channel,message,user.display_name)
fourInARowTheirTurn, piece = fiarReactionTest(channel,message,"#"+str(user.id))
if fourInARowTheirTurn:
place = emojiToNumber(reaction.emoji)
await fiar(channel," place "+str(piece)+" "+str(place),user.display_name)
await fiar(channel," place "+str(piece)+" "+str(place),user.id)
# Runs the whole shabang
client.run(token)