'Discord.py bot not sending messages in a discord server but sends messages in DM's

I have a discord.py bot that when the command is sent through DM, it works. When the command is ran through a server, nothing happens. There is no errors or tracebacks. Here is my code so far.

import discord
from discord.ext import commands

bot = discord.Bot()

TOKEN = "MyToken"

bot = commands.Bot(command_prefix="$")

@bot.command()
async def test(ctx, arg):
    await ctx.send(arg)

bot.run(TOKEN)

I don't know whats happening. I gave it the right permissions but it still wont do anything.



Solution 1:[1]

So, I don't know for sure if this is the issue, but try this:

I have my bot set as:

bot = commands.Bot(command_prefix= '$', description="<desc>")

Rather than yours which is BOTH of these:

bot = discord.Bot()

&

bot = commands.Bot(command_prefix="$")

I think it's only detecting the first value you've given your bot.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 clxrity