title: Python Discord bot not responding in servers
body: <p>I have run into a very strange problem and I would appreciate any help that comes my way
  So I made a discord bot using discord.py library and hosted it on Heroku. It was working perfectly well. Until recently had to take it down for some development. Now when I uploaded it again it does not work. Here is a summary of what is going on</p>
  <ul>
  <li>The bot does have online status on Discord.</li>
  <li>The bot responds perfectly normal in DMs.</li>
  <li>The bot does not receive and respond to any message in any server.</li>
  <li>When I run the exact same code file on my PC it works perfectly normal but when I run it on Heroku I get this issue</li>
  </ul>
  <p>I dont think the code has anything to do with it and I'm thinking it has something to do with Heroku. Can anyone help me out.
  Here is the main code in case if anyone needs it</p>
  <pre><code>import os,random
  import discord
  from discord.ui import Button, View
  from discord.ext import commands
  from dotenv import load_dotenv
  from speech_recognition_module import recognize_speech
  from RPS import RPS
  import yt_dlp
  from youtubesearchpython import VideosSearch
  import json
  from requests import get
  
  
  load_dotenv()
  TOKEN = os.getenv('DISCORD_TOKEN')
  intents = discord.Intents.default()
  client = commands.Bot(command_prefix=&quot;!&quot;,intents=intents)
  
  #------------Bot Starting--------------------------
  @client.event
  async def on_ready():
      guilds = client.guilds
      print(
          f'{client.user} is connected to the following guild:\n'
          # f'{guild.name}(id: {guild.id})'
      )
      for guild in guilds:
          print(f&quot;{guild.name}&quot;)
  
  #--------- Hello command to display a list of available commands-----------------
  @client.command()
  async def hello(ctx):
      username = str(ctx.author).split(&quot;#&quot;)[0]
      embedVar = discord.Embed(title=&quot;List of Avaiable Commands&quot;, description='''Here is a list of currently available commands:
                     
  **General Interaction with the Bot:**
      !hello - display a list of available commands
      !bye - a nice lil goodbye message from CodTheBot
      !listen - listens to your audio, converts it into text and sends it to the server
      
  **Rock, Papers, Scissors Commands:**
      !playRPS - play a Rock, Paper, Scissors game
      
  **TicTacToe Commands:**
      !tictactoe @user1 @user2 - runs a tictactoe game between the tagged users
      !place *n* - marks your choice at the nth value box
      
  **Music Commands:**
      !join - CodTheBot joins the vc
      !play *songname* - plays the desired song
      !pause - pause the song
      !resume - resume the song
      !disconnect - CodTheBot leaves the vc
      
  **Memes Commands:**
      !meme - displays a random meme from reddit''',color=0xFF0000)
  
      await ctx.send(f&quot;Hello I am CODtheBOT. You must be {username}&quot;)
      await ctx.send(embed=embedVar)
                          
                                       
   #----------------- Bye Command---------------------------------------
  @client.command()
  async def bye(ctx):
      username = str(ctx.author).split(&quot;#&quot;)[0]
      
  
      await ctx.send(f'See you later {username}!')
  
  
  #----------------Listen Command to listen to audio ,convert it to text and send it to server---
  @client.command()
  async def listen(ctx):
      username = str(ctx.author).split(&quot;#&quot;)[0]
  
      msg = await ctx.send(f'Go on I am listening')
      text = recognize_speech()
      await msg.edit(&quot;Hey Everyone!&quot;)
      await ctx.send(f'{username} said: {text}')    
  
  
  #--------------------Rock Paper Scissors Game--------------
  @client.command()
  async def playRPS(ctx):
      username = str(ctx.author).split(&quot;#&quot;)[0]
      
  
  
  
      await ctx.send(f'Hey {username} Lets Play. Make your choice')
  
  
      button_Rock = Button(emoji=&quot;✊&quot;)
      button_Paper = Button(emoji=&quot;✋&quot;)
      button_Scissor = Button(emoji=&quot;✌&quot;)
      
      async def btn_rock_callback(interaction, custom_id=&quot;rock&quot;):
  
  
          user2, field, game_stat = RPS(custom_id)
  
          embedVar = discord.Embed( description=f&quot;You chose Rock\nI choose {user2}&quot;, color=0x00ff00)
          await interaction.response.edit_message(content=field, embed=embedVar, view=None)
  
  
          embedVar = discord.Embed(title=game_stat[&quot;message&quot;], description=game_stat[&quot;description&quot;], color=game_stat[&quot;color&quot;])
          await ctx.send(embed=embedVar)
  
      async def btn_paper_callback(interaction, custom_id=&quot;paper&quot;):
  
  
          user2, field, game_stat = RPS(custom_id)
  
          embedVar = discord.Embed( description=f&quot;You chose Paper\nI choose {user2}&quot;, color=0x00ff00)
          await interaction.response.edit_message(content=field, embed=embedVar, view=None)
  
  
          embedVar = discord.Embed(title=game_stat[&quot;message&quot;], description=game_stat[&quot;description&quot;], color=game_stat[&quot;color&quot;])
          await ctx.send(embed=embedVar)
  
      async def btn_scissor_callback(interaction, custom_id=&quot;scissor&quot;):
  
  
          user2, field, game_stat = RPS(custom_id)
  
          embedVar = discord.Embed( description=f&quot;You chose Scissors\nI choose {user2}&quot;, color=0x00ff00)
          await interaction.response.edit_message(content=field, embed=embedVar, view=None)
  
  
          embedVar = discord.Embed(title=game_stat[&quot;message&quot;], description=game_stat[&quot;description&quot;], color=game_stat[&quot;color&quot;])
          await ctx.send(embed=embedVar)
  
  
      view_var = View()
      view_var.add_item(button_Rock)
      view_var.add_item(button_Paper)
      view_var.add_item(button_Scissor)
  
      start_field= &quot;:right_fist:      :left_fist:&quot;
      await ctx.send(start_field,view=view_var)
      button_Rock.callback = btn_rock_callback
      button_Paper.callback = btn_paper_callback
      button_Scissor.callback = btn_scissor_callback
      
  #----------Tic Tac Toe Game------------------------------------------
  @client.command()
  async def tictactoe(ctx, p1: discord.Member, p2: discord.Member):
      global player1
      global player2
      global turn
      global game_over
      game_over = True
      global count
  
      if game_over:
          global board
          board = [&quot;:white_large_square:&quot;]*9
          game_over = False
          count = 0
  
          player1 = p1
          player2 = p2
  
          #Print blank board
          line = &quot;&quot;
          for x in range(len(board)):
              if x==2 or x==5 or x==8:
                  line += &quot; &quot; + board[x]
                  await ctx.send(line)
                  line = &quot;&quot;
              else:
                  line += &quot; &quot; + board[x]
          #Determine who goes first
          num = random.randint(1,2)
          if num == 1:
              turn = player1
              await ctx.send(&quot;It is &lt;@&quot; + str(player1.id) + &quot;&gt;'s turn.&quot;)
          else:
              turn = player2
              await ctx.send(&quot;It is &lt;@&quot; + str(player2.id) + &quot;&gt;'s turn.&quot;)
      else:
          await ctx.send(&quot;A game is already in progress. Please finish it.&quot;)
  
  #----------------Tic Tac Toe Placement Handling ----------------------
  
  @client.command()
  async def place(ctx, position: int):
      global turn
      global count
  
  
      def checkwin(winning_conditions, mark,board):
          global game_over
          for condition in winning_conditions:
              if board[condition[0]] == mark and board[condition[1]] == mark and board[condition[2]] == mark:
                  game_over = True
  
  
      winning_conditions = [
      [0,1,2],
      [3,4,5],
      [6,7,8],
      [0,3,6],
      [1,4,7],
      [2,5,8],
      [0,4,8],
      [2,4,6],
  ]
  
      if not game_over:
          mark = &quot;&quot;
          if turn == ctx.author:
              if turn == player1:
                  mark = &quot;:regional_indicator_x:&quot;
              else:
                  mark = &quot;:o2:&quot;
              if 0 &lt; position &lt; 10 and board[position-1] == &quot;:white_large_square:&quot;:
                  board[position-1] = mark
                  count += 1
                       # will try to make this into a function
                  line = &quot;&quot;
                  for x in range(len(board)):
                      if x==2 or x==5 or x==8:
                          line += &quot; &quot; + board[x]
                          await ctx.send(line)
                          line = &quot;&quot;
                      else:
                          line += &quot; &quot; + board[x]
                  checkwin(winning_conditions, mark,board)
                  if game_over:
                      await ctx.send(mark + &quot; wins!&quot;)
                  elif count &gt;= 9:
                      await ctx.send(&quot;It's a tie!&quot;)
                  #Switch turns
                  if turn == player1:
                      turn = player2
                  elif turn == player2:
                      turn = player1
  
              else:
                  await ctx.send(&quot;Please choose an integer between 1 and 9 and an unmarked tile.&quot;)
          else:
              await ctx.send(&quot;It is not your turn.&quot;)
      else:
          await ctx.send(&quot;Please start a new game first.&quot;)
          
  
  #----------------Tic Tac Toe Error Handling ----------------------
  
  @tictactoe.error
  async def tictactoe_error(ctx, error):
      if isinstance(error, commands.MissingRequiredArgument):
          await ctx.send(&quot;Please mention two players for this command.&quot;)
      elif isinstance(error, commands.BadArgument):
          await ctx.send(&quot;Please make sure to mention/ping players i.e. &lt;@playerid&gt;&quot;)
  
  @place.error
  async def place_error(ctx, error):
      if isinstance(error, commands.MissingRequiredArgument):
          await ctx.send(&quot;Please enter a position to mark.&quot;)
      elif isinstance(error, commands.BadArgument):
          await ctx.send(&quot;Please make sure to enter an integer.&quot;)
  
  
  #---------------------------------Music player---------------------------------------
  
  
  @client.command()
  async def join(ctx):
      if ctx.author.voice is None:
          await ctx.send(&quot;You're not in a voice channel&quot;)
      voice_channel = ctx.author.voice.channel
      if ctx.voice_client is None:
          await voice_channel.connect()
      else:
          await ctx.voice_client.move_to(voice_channel)
          
  @client.command()
  async def disconnect(ctx):
      await ctx.voice_client.disconnect()
      
  @client.command()
  async def play(ctx,url):
      ctx.voice_client.stop()
      # FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 
      # 'options': '-vn'}
      YDL_OPTIONS = {'format': 'bestaudio'}
      vc = ctx.voice_client
      
      with yt_dlp.YoutubeDL(YDL_OPTIONS) as ydl:
          url = VideosSearch(url, limit = 2)
          y=url.result()
          x=y['result'][0]['link']
          print(x)
          info = ydl.extract_info(x, download = False)
          url2 = info ['formats'][0]['url']
          print (url2)
          source = await discord.FFmpegOpusAudio.from_probe(url2)# **FFMPEG_OPTIONS)
          vc.play(source)
          embed_var=discord.Embed(title=&quot;Now playing - &quot;, description=y['result'][0]['title'], color=0x00FF00)
          embed_var.set_image(url=y['result'][0]['thumbnails'][0]['url'])
          await ctx.send(embed=embed_var)
          
  
  @client.command()
  async def pause(ctx):
      ctx.voice_client.pause()
      await ctx.send(&quot;Paused ⏸️&quot;)
  
  @client.command()
  async def resume(ctx):
      ctx.voice_client.resume()
      await ctx.send(&quot;Resumed ▶️&quot;)
      
      
  #----------------- Random Meme Gennerator-----------------------------
      
  @client.command()
  async def meme(ctx): 
      content = get(&quot;https://meme-api.herokuapp.com/gimme&quot;).text
      data = json.loads(content)
      meme = discord.Embed(title=f&quot;{data['title']}&quot;, color = 0x00FF00)
      meme.set_image(url=f&quot;{data['url']}&quot;)
      await ctx.reply(embed=meme)
      
  
  client.run(TOKEN)
  
  
  
  
  </code></pre>