#๐ My Discord bot cannot send messages
77 messages ยท Page 1 of 1 (latest)
@buoyant lake
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
here is my code
import discord
from discord import commands
TOKEN = "my token"
intents = discord.Intents.default()
client = discord.Client(command_prefix='!', intents=intents)
@client.event
async def on_ready():
print(f'{client.user} is connected to the following servers:\n')
for server in client.guilds:
print(f'{server.name} (id: {server.id})')
client.run("my token")
Bot = discord.bot(intents=discord.intents.all(),command_prefix="!")
@client.command()
async def test(ctx):
embed = discord.Embed(title="Test", description="Testing testing", color=discord.Color.blurple())
await ctx.send(embed=embed)
Im not master in discord bots, but check your bot in discord developer portal, there's should be settings, you need to turn it on
Ill check it, edit:im not home sry, i cant provide screenshots
Its in bot page, if i remember correctly
to get the number is there but I dont see were to put it
ill took up rq
I did it, these
hmmm it still doesent work it must be the code thanks for the help though ill work on it
Does it see messages?
ya
Oh, im blind, you run your bot before defining test command
what?
You need to put "client.run" at the end of your code
ya i defenitly did somthing wrong with the discord side of things becuase it looks like the code should work ill watch a toturial later thanks so much for the help
Put "client.run" in the bottom of your code
...
async def test():
...
# your code
client.run(TOKEN)
ya I did that still nothing
Send me your new code, ill run it in 10-20 mins
import discord
from discord import commands
TOKEN = "my token"
intents = discord.Intents.default()
client = discord.Client(command_prefix='!', intents=intents)
@client.event
async def on_ready():
print(f'{client.user} is connected to the following servers:\n')
for server in client.guilds:
print(f'{server.name} (id: {server.id})')
client.run("my token")
Bot = discord.bot(intents=discord.intents.all(),command_prefix="!")
@client.command()
async def test(ctx):
embed = discord.Embed(title="Test", description="Testing testing", color=discord.Color.blurple())
await ctx.send(embed=embed)
client.run(my token)
why are you declaring client then bot?

oh i see, yeah there is problem, like GuiSai said
do I only do one or do I switch them?
?
kep the one at the top.
when i created bot, i used only bot, maybe theres new update
k thanks
wait client run at the bottom.
not the one inthe middle
remove the client run in the middle
so only remove middle keep everything els
well the discord.Bot does nothing. so you can remove that too.
so remove client run in middle and bot=discord
now im getting an error client has no attribute for command
import discord
from discord import commands
TOKEN = "my token"
bot = discord.bot(intents=discord.intents.all(),command_prefix="!")
@bot.event
async def on_ready():
print(f'{client.user} is connected to the following servers:\n')
for server in client.guilds:
print(f'{server.name} (id: {server.id})')
@bot.command()
async def test(ctx):
embed = discord.Embed(title="Test", description="Testing testing", color=discord.Color.blurple())
await ctx.send(embed=embed)
bot.run(TOKEN)
do that instead
client is mostly for using slash commands
module 'discord' has no attribute 'intents'
'module' object is not callable
are you running discord.py or pycord first
sorry im really new how do I tell?
mmm did you do pip install discord.py or pycord
okay
make a slight change to ur code
change from discord import to
form discord.ext import commands
when I did that it gave the same error
ok no errors and my bot is online so if I do !test it should respond?
OMG
Thank you so much
it worked
!close
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.