Discord Bot code

**If this does not work, this is because I can’t share my discord bot token. The line where it says token = ‘ ‘, you need to insert your own code.**

import datetime
import random
import string
import time


import httpx as httpx

letters = string.ascii_lowercase
import discord
from discord.ext import commands
from discord import app_commands
token = ''

url = 'http://blargh.ddns.net:1999/game/result'
helpme_url = 'https://sorieboi.com/didbot-commands/'
intents = discord.Intents.all()
bot = commands.Bot(command_prefix='!', intents=intents)
bigger = False
Smaller = False
#           a    b   c   d   e   f   g  h  i  j    k l    m  n   o  p  q  r    s  t u   v  w  x y   z
SorieBoi = ['@','#','$','%','^','&','*,','(',')','-','=','_','+',':','{','}','[',']','>','<',',','|', '/','k','f','e', ' ']
@bot.event
async def on_ready():
    print(f'{bot.user.name} has connected to Discord!')
@bot.command(name='idk',help='idk')
async def o(ctx):
    r = httpx.post(url, json={
  "game_name": "test",
  "user_name": "soren_diddy",
  "recorded_at": str(datetime.datetime.now())
})
    print(r)



@bot.command(name="ip", help='tells you the weather in Denver Colorado')
async def get_ip(ctx):
    async with httpx.AsyncClient() as client:
        r = await client.get('https://ifconfig.io/all.json')
    await ctx.send(r.json())

@bot.command(name='helpme', help='Tells you all the commands')
async def help_commands(ctx):
    await ctx.send(helpme_url)
    await ctx.send('**THIS IS NOT A RICKROLL** it is all commands.')
@bot.command(name='code', help="Turns a message into The SorieBoi language.")
async def code(ctx,*, message: str):
    print(len(SorieBoi))
    sorie_map = {letter: SorieBoi[i] for i, letter in enumerate(string.ascii_lowercase + ' ')}
    print(sorie_map)

    new_message = ''
    for char in message:
        new_message += sorie_map[char]
    await ctx.send(new_message)


@bot.command(name='math', help='does math')
async def math(ctx,*,equation: str):
    problem = equation.replace(' ', '')
    if '+' in problem:
        new_problem = problem.split('+')

        number_1 = new_problem[0]
        number_2 = new_problem[1]
        new_number_1 = int(number_1)
        new_number_2 = int(number_2)
        answer = new_number_1 + new_number_2
        await ctx.send(answer)
    if '-' in problem:
        sub_problem = problem.split('-')
        sub_1 = sub_problem[0]
        sub_2 = sub_problem[1]
        new_sub_1 = int(sub_1)
        new_sub_2 = int(sub_2)
        answer_sub = new_sub_1 - new_sub_2
        await ctx.send(answer_sub)
    if '*' in problem:
        mult_problem = problem.split('*')
        mult_1 = mult_problem[0]
        mult_2 = mult_problem[1]
        new_mult_1 = int(mult_1)
        new_mult_2 = int(mult_2)
        answer_mult = new_mult_1 * new_mult_2
        await ctx.send(answer_mult)
    if '/' in problem:
        div_problem = problem.split('/')
        div_1 = div_problem[0]
        div_2 = div_problem[1]
        new_div_1 = int(div_1)
        new_div_2 = int(div_2)
        answer_div = new_div_1 / new_div_2
        await ctx.send(answer_div)
@bot.command(name='rigsby', help='Rigsby Trivia')
async def rigsby(ctx):
    await ctx.send('Welcome to Rigsby Trivia. I will ask you questions. Try to win.')
    await ctx.send('What is Rigsby?')
    await ctx.send('a = dog')
    await ctx.send('b = cat')
    await ctx.send('c = hamster')
    await ctx.send('d = egg')
    await ctx.send("guess one.")
    answers = ['a','b','c','d']
    guess = await bot.wait_for('message')

    chance = 2
    if guess.content.lower() not in answers:
        await ctx.send('Really? Is that really an answer?')
        await ctx.send('I will give you 1 more chance. Answer correctly.')
        guess = await bot.wait_for('message')
        chance = chance - 1

        if guess.content.lower() not in answers:
            chance = chance - 1
            if chance == 0:
                await ctx.send('Stop.')
                return
    if guess.content.lower() == 'a':
        await ctx.send("You made it to the next round! Good Job!")
    else:
        await ctx.send("You lose. Try again next time!")
        return
    await ctx.send('Next round. Is Rigsby a good boi?')
    await ctx.send('yes or no? Guess Yes or No.')
    true_or_false = ['yes', 'no']
    guess = await bot.wait_for('message')
    if guess.content.lower() not in true_or_false:
        if chance == 0:
            await ctx.send('Come on man. You lose')
            return
        await ctx.send('Choose one of Yes or No.')
        chance = chance - 1
    if guess.content.lower() == 'yes':
        if chance == 0:
            await ctx.send("You got it correct but, you lost.")
            return
        await ctx.send("Good job! You made it to next round.")
    else:
        await ctx.send("You lost. Try again next time.")
        return
    await ctx.send('What are some things Rigsby likes to do? to do?')
    await ctx.send('a = Play, b = Snuggle, c = Lay by the fire, d = all of the above')
    await ctx.send('a,b,c or d')
    guess = await bot.wait_for('message')
    if guess.content.lower() not in answers:

        if chance == 0:
            await ctx.send('Come on man. You lose')
            return
        chance = chance - 1
        await ctx.send('That does not seem to be an answer. You made it this far atleast try.')
    if guess.content.lower() == 'd':
        if chance == 0:
            await ctx.send("Getting there. But you guessed non valid answers.")
            return
        await ctx.send("Good job. You are now a Rigsby knower")
    else:
        await ctx.send("You are getting there! You almost got to the next question")
        return
    await ctx.send("What is Rigsbys birthday?")
    await ctx.send('a = September 24, b = June 18, c = March 21, d = June 28')
    guess = await bot.wait_for('message')
    if guess.content.lower() not in answers:

        if chance == 0:
            await ctx.send('Come on man. You lose')
            return
        chance = chance - 1
        await ctx.send('Try a valid guess. You have:' + str(chance) + 'guesses')
    if guess.content.lower() == 'b':
        await ctx.send("Good job. You are now a pog + knower of da rig")
    else:


        await ctx.send("Close. You died out on Rigsby Knower rank.")
        return
    await ctx.send("What kind of dog is rigsby?")
    await ctx.send('a = Golden Retriever, b = German Shepard, c = Beagle, d = Rhodesian Ridgeback')
    guess = await bot.wait_for('message')
    if guess.content.lower() not in answers:

        if chance == 0:
            await ctx.send('Come on man. You lose')
            return
        await ctx.send('Ahhhhh! Do not lose now! You are a Rigsby knower + a pog')
        chance = chance - 1
    if guess.content.lower() == 'd':

        await ctx.send('You are a super amogus pog! Your rank = Rigsby Knower + pog + amogus pog')
    else:
        await ctx.send('Noooooo. You were a Rigsby knower + a pog. Try again!')
        return
    await ctx.send('What is Rigsbys favorite toy?')
    await ctx.send('a = You, b = Avacado, c = bone, d = Small children')
    guess = await bot.wait_for('message')
    if guess.content.lower() not in answers:

        if chance == 0:
            await ctx.send('Come on man. You lose')
            return
        await ctx.send("If you really lose now i will be a sadge amogus. You are a Rigsby knower + pog + amogus pog")
        chance = chance - 1
    if guess.content.lower() == 'a':
        if chance == 0:
            await ctx.send("NOOOOO! You were a Rigsby knower + pog + amogus pog! And you got it correct!")
            return
        await ctx.send("Wow! Amazing, that was one of the hardest questions.")
        await ctx.send("Your rank = Rigsby Knower + POG + AMOGUS POG + RIGSBY ENJOYER!!")
    else:
        await ctx.send("NOOOOO! You were a Rigsby knower + pog + amogus pog!")
        return

    await ctx.send("How many hours does rigsby sleep a day? This will be estimated.")
    await ctx.send('a = about 20. b = about 5, c = about 24, d = imagine sleeping. 0 hours')
    guess = await bot.wait_for('message')
    if guess.content.lower() not in answers:
        if chance == 0:
            await ctx.send('Come on man. You lose')
            return
        await ctx.send("Plz no i literally will cry if you lose.Your rank = Rigsby Knower + POG + AMOGUS POG + RIGSBY ENJOYER")
        chance = chance - 1
    if guess.content.lower() == 'a':
        await ctx.send("POGGGERSSSS! Your rank = Rigsby Knower + POG + AMOGUS POG + RIGSBY ENJOYER + RIGSBY DOUBLE + POG ")
        print('win')
    else:
        await ctx.send("me: 😭 Your rank = Rigsby Knower + POG + AMOGUS POG + RIGSBY ENJOYER")
        await ctx.send('U got dis!')
        return
    await ctx.send("Don't lose. What color is Rigsby's collar?")
    await ctx.send("a= blue, b = red c = green d = white")
    guess = await bot.wait_for('message')
    if guess.content.lower() not in answers:
        if chance == 0:
            await ctx.send("Try real answers lol")
            return
        await ctx.send("Read the questions carefully. Was that an answer")
        chance = chance - 1
    if guess.content.lower() == 'b':
        await ctx.send("POGGGGERSSS YOUR SO CLOSE! Your rank = Rigsby Knower + POG + AMOGUS POG + RIGSBY ENJOYER + RIGSBY DOUBLE + POG ")
    else:
        await ctx.send('Try again. U do be wrong. I do admit that these questions are only if you were like a vet or smth')
        await ctx.send("Your rank = Rigsby Knower + POG + AMOGUS POG + RIGSBY ENJOYER + RIGSBY DOUBLE + POG")
        return
    await ctx.send("Do not lose. This is the final question. No pressure lol")
    await ctx.send("How many toe nails of rigbys are white?")
    await ctx.send('a = 5, b = 3, c = 1, d = none')
    guess = await bot.wait_for('message')
    if guess.content.lower() not in answers:
        if chance == 0:
            await ctx.send("WHYYYYYYYYYYY!!!!!!!!!!!!?????? HOW HARD IS IT TO ANSWER A VALID GUESS????")
            return
        await ctx.send("Deep breath")
        chance = chance -1
    if guess.content.lower() == 'c':
        await ctx.send('Noooooo. The last question. You lost....')
        time.sleep(1)
        await ctx.send("SIKE, YOU WON! I CANT BELIVE THIS!")
        await ctx.send('Your rank = Rigsby Knower + POG + AMOGUS POG + RIGSBY ENJOYER + RIGSBY DOUBLE + POG + A RIGSBY OWNER SUPER POG!!')
        await ctx.send('Gmail me at soren.sturdivant@gmail.com a screenshot of the win.')
        winner = guess.author
        await ctx.send("Great job: " + str(winner))
        r = httpx.post(url, json={
            'game_name': "Rigsby Trivia",
            'user_name': str(winner),
            "recorded_at": str(datetime.datetime.now())
        })
    else:
        await ctx.send(":(")
        await ctx.send("Rigsby is a sad boi now.")
        await ctx.send("You were a Rigsby Knower + POG + AMOGUS POG + RIGSBY ENJOYER + RIGSBY DOUBLE + POG")
        await ctx.send("Welp, try again next time.")



    return

@bot.command(name='99', help='Responds with a random quote from Brooklyn 99')
async def nine_nine(ctx):
    brooklyn_99_quotes = [
        'I\'m the human form of the 💯 emoji.',
        'Bingpot!',
        (
            'Cool. Cool cool cool cool cool cool cool, '
            'no doubt no doubt no doubt no doubt.'
        ),
    ]

    response = random.choice(brooklyn_99_quotes)
    await ctx.send(response)


playing_games = {}


@bot.command(name='number',
             help='Plays a quick game of quess the number\n Do the command !number (number you want to guess) to start the game')
async def number_guess(ctx, guess: int):
    if ctx.author not in playing_games:
        number = random.randint(1, 100)
        print(number)
        guesses = 10
        playing_games[ctx.author] = (number, guesses)
    else:
        number, guesses = playing_games[ctx.author]
    print(playing_games)

    if guesses == 0:
        await ctx.send(f'Rip, you died. Care to try again?')
        del playing_games[ctx.author]
        return
    if guess > 100:
        await ctx.send(f"Your number is too big. It has to be between 1 and 100.")
        return
    if guess < 0:
        await ctx.send(f"Your number is too small. It has to be between 1-100.")
        return

    if guess == number:

        await ctx.send(f"You won! Good job!")
        del playing_games[ctx.author]
        return
    elif guess > number:

        await ctx.send(f"Try again. Your guess is bigger than the number.")
        guesses = guesses - 1

    elif guess < number:

        await ctx.send(f"You are close. Your number is less than the number.")
        guesses = guesses - 1
    playing_games[ctx.author] = (number, guesses)


WORDS = [
    'soren',
    'did',
    'pog', "First dc bot", "Mom is pog", "Dad is pog", "Do you like this?", "Rip Nugget", "Rigsby is a dog",
    "I like dogs", "Python is fun", "School is cringe"
]

GAMES = {}


def find(s, ch):
    return [i for i, ltr in enumerate(s) if ltr == ch]



@bot.command(name='hangman', help='Play a game of hangman')
async def hangman(ctx, guess: str):
    # check to see if we've started a game
    if ctx.author not in GAMES:
        word = random.choice(WORDS)
        GAMES[ctx.author] = (15, word, '_' * len(word))
        await ctx.message.author.send("Lets play a game of hangman!")



    print(GAMES)
    guesses, word, current = GAMES[ctx.author]
    if guesses == 0:
        await ctx.send('RIP, you died. The word was ' + word)
        del GAMES[ctx.author]
        return

    locations = find(word, guess)
    current = list(current)
    for location in locations:
        current[location] = guess
    current = ''.join(current)

    if current == word:
        # The game is over!
        winner = GAMES[ctx.author]


        await ctx.send(f'Congrats! You got the word! It was: {word}')
        r = httpx.post(url, data={
            "game_name": "Hangman",
            'user_name': str(winner),
            "recorded_at": str(datetime.datetime.now())
        })
        del GAMES[ctx.author]
        return

    # Store the game info
    GAMES[ctx.author] = (guesses - 1, word, current)

    await ctx.send(f'Current word: {current} - {guesses} remaining.')


choices = ['r', 'p', 's']


@bot.command(name='rps', help='Plays a quick game of rock,paper,scissors!')
@app_commands.describe(guess="You must guess a r, p, or a s.")
async def rock(ctx, guess: str):
    computer_choice = random.choice(choices)
    print(computer_choice)
    if guess == 'r':
        if computer_choice == 's':
            await ctx.send("Good job, You won!")
        elif computer_choice == 'r':
            await ctx.send('It was a tie.')
        else:
            await ctx.send("The computer won. You lost.")
    if guess == 'p':
        if computer_choice == 'r':
            await ctx.send('Good job, You won!')
        if computer_choice == 'p':
            await ctx.send('It was a tie.')
        else:
            await ctx.send('The computer won. You lost')
    if guess == 's':
        if computer_choice == 's':
            await ctx.send("It was a tie.")
        elif computer_choice == 'p':
            await ctx.send("Good job, You won!")
        else:
            await ctx.send("The computer won. You lost.")


@bot.command(name='roll', help='Rolls a random number 1-1000')
async def roll_random(ctx):
    number = random.randint(1, 1000)
    await ctx.send(number)


@bot.command(name='password', help='Makes a random password')
async def random_password(ctx):
    type_choice = ['letter', 'number']

    password_data = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

    for i in range(10):
        random_choice = random.choice(type_choice)
        if random_choice == 'letter':
            letter = random.choice(letters)
            password_data[i] = letter
        else:
            number = random.randint(1, 9)
            password_data[i] = str(number)

    await ctx.message.author.send(''.join(password_data))

@bot.command(name='coinflip', help='flips a coin')
async def coin_flip(ctx,call):
    coin_options = [1 , 2]
    computer_choice = random.choice(coin_options)
    if call == 1:
        if computer_choice == 1:
            await ctx.send("You lost. The computer chose tails.")
        else:
            await ctx.send("You won. The computer chose heads")
    else:
        if computer_choice == 2:
            await ctx.send("You won. The computer chose tails")
        else:
            await ctx.send("You lost. The computer chose heads")
@bot.command(name='sus',help='sus')
async def sus(ctx):
    await ctx.send("Who is sus and why?")
    guess = await bot.wait_for('message')
    acuzzer = guess.author
    if 'sus' in guess.content.lower():
        await ctx.send("They are very sus.")
    else:
        await ctx.send('Are they sus though' + '  ' + str(acuzzer) + '?')
difficulties = ['easy', 'medium', 'hard', 'extreme']
@bot.command(name='test', help='take a math test of any difficulty')
async def math_test(ctx):
    correct = 10
    await ctx.send('What difficulty do you want?')
    await ctx.send('easy, medium, hard, or extreme?')
    difficulty = await bot.wait_for('message')
    if difficulty.content.lower() not in difficulties:
        await ctx.send('Choose a real difficulty next time.')
        return
    if difficulty.content.lower() == 'easy':
        await ctx.send('There will be 10 questions')
bot.run(TOKEN)