-1

Consider:

import os
import discord
import random
from discord.ext import commands

client = discord.Client()
bot = commands.Bot(command_prefix='!')
my_secret = os.environ['cleint']

Player = ''
ComPoint = 0
PlayerPoint = 0
turn = 0
gameOver = True
legalMoves = ['rock', 'paper', 'scissors']

@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('$hello'):
        await message.channel.send('Hello!')

@bot.command
async def rcp(ctx):
  global Player
  global turn
  global count
  global PlayerPoint
  global ComPoint


if turn == 3:
    turn = 0
    count = 0
    PlayerPoint = 0
    ComPoint = 0


  Player = ''
  with open('images/rock_paper_scissors__2x.png', 'rb') as rcp:
    picture = discord.File(rcp)
    await ctx.send(file = picture)
    await picture.add_reaction(':rock:')
    await picture.add_reaction(':roll_of_paper:')
    await picture.add_reaction(':scissors:')

comRandom = random.choice(legalMoves)
for reaction in picture.reactions:
  ''' Rock '''
  if reaction.emoji == ':rock:' and comRandom == ':scissors:':
    turn += 1
    PlayerPoint += 1
    ctx.send("PLAYER: ", PlayerPoint, "COMPUTER: ", ComPoint)
  elif reaction.emoji == ':rock:' and comRandom == ':paper:':
    turn += 1
    ComPoint += 1
    ctx.send("PLAYER: ", PlayerPoint, "COMPUTER: ", ComPoint)
  elif reaction.emoji == ':rock:' and comRandom == ':rock:':
    turn += 1
    ctx.send("PLAYER: ", PlayerPoint, "COMPUTER: ", ComPoint)

  ''' Paper '''
  if reaction.emoji == ':paper:' and comRandom == ':scissors:':
    turn += 1
    ComPoint += 1
    ctx.send("PLAYER: ", PlayerPoint, "COMPUTER: ", ComPoint)
  elif reaction.emoji == ':paper:' and comRandom == ':paper:':
    turn += 1
    ctx.send("PLAYER: ", PlayerPoint, "COMPUTER: ", ComPoint)
  elif reaction.emoji == ':paper:' and comRandom == ':rock:':
    turn += 1
    PlayerPoint += 1
    ctx.send("PLAYER: ", PlayerPoint, "COMPUTER: ", ComPoint)

  ''' Scissors '''
  if reaction.emoji == ':scissors:' and comRandom == ':scissors:':
    turn += 1
    ctx.send("PLAYER: ", PlayerPoint, "COMPUTER: ", ComPoint)
  elif reaction.emoji == ':scissors:' and comRandom == ':paper:':
    turn += 1
    PlayerPoint += 1
    ctx.send("PLAYER: ", PlayerPoint, "COMPUTER: ", ComPoint)
  elif reaction.emoji == ':scissors:' and comRandom == ':rock:':
    turn += 1
    ComPoint += 1
    ctx.send("PLAYER: ", PlayerPoint, "COMPUTER: ", ComPoint)


client.run(my_secret)

What's my problem? I think the problem is from where I send the image in Discord. As it shows when I open the image if I bring it out of the block. It gives me another error.

I would try out doing like image.reaction, but I think it would be wrong.

I won't think the problem is from the logic of the game, because it doesn't even start when I use the command !rcp.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
bigbng
  • 11
  • 1
  • 3
    Have you gotten any errors or traceback? Can you edit your answer to include this? Your indentation looks strange for your command too, have you copied and pasted your code correctly? – Bagle Jun 02 '21 at 02:18
  • Also, have a look at this answer as well: [Why does on_message stop commands from working?](https://stackoverflow.com/a/49331419/14420546) – Bagle Jun 02 '21 at 02:19
  • In `my_secret = os.environ['cleint']`, "cleint" is a misspelling of "[client](https://en.wiktionary.org/wiki/client#Noun)". What is the consequence of this misspelling (not a rhetorical question)? – Peter Mortensen Jun 03 '21 at 07:52

1 Answers1

-1

I suggest trying simply

await ctx.send(file=discord.File('images/rock_paper_scissors__2x.png')

instead of

with open('images/rock_paper_scissors__2x.png', 'rb') as rcp:

Because open can cause issues (Discord.py Bot sending file to Discord Channel)

You also may have some pollution issues because your command function is called rcp and your file is being called rcp, which this would also fix.

Alyx
  • 436
  • 4
  • 16