#๐Ÿ”’ My Discord bot cannot send messages

77 messages ยท Page 1 of 1 (latest)

buoyant lake
#

Hello I am new to coding and am trying to make a discord bot for fun. Its nothing special but am just trying to get it to respond to ! test when i run or debug it it dosent look like anything is wrong but it will not respond in discord

spark mortarBOT
#

@buoyant lake

Python help channel opened

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.

buoyant lake
#

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)
rain crag
#

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

buoyant lake
#

thanks

#

i think it might be permissions intger i cant find were to put the number

rain crag
buoyant lake
#

ill took up rq

buoyant lake
#

hmmm it still doesent work it must be the code thanks for the help though ill work on it

rain crag
#

Does it see messages?

buoyant lake
rain crag
rain crag
buoyant lake
#

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

rain crag
#

Put "client.run" in the bottom of your code

...
async def test():
    ...
# your code 
client.run(TOKEN)
buoyant lake
#

ya I did that still nothing

rain crag
buoyant lake
#

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)

violet lagoon
rain crag
#

oh i see, yeah there is problem, like GuiSai said

buoyant lake
wicked knot
#

kep the one at the top.

rain crag
#

when i created bot, i used only bot, maybe theres new update

buoyant lake
wicked knot
#

wait client run at the bottom.

#

not the one inthe middle

#

remove the client run in the middle

buoyant lake
wicked knot
#

well the discord.Bot does nothing. so you can remove that too.

buoyant lake
wicked knot
#

yes.

#

and then try it

buoyant lake
wicked knot
#

wait if you want to use !

#

as your command prefix

buoyant lake
#

yes

#

thats what it is et to

wicked knot
#
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

buoyant lake
#

module 'discord' has no attribute 'intents'

wicked knot
#

capital I

#

Intents.all()

buoyant lake
wicked knot
#

send a ss?

#

also change all occurnces of client to bot

buoyant lake
wicked knot
buoyant lake
wicked knot
buoyant lake
wicked knot
#

okay

#

make a slight change to ur code

#

change from discord import to
form discord.ext import commands

buoyant lake
wicked knot
#

oh and then change discord.bot

#

to commands.bot

#

commands.Bot()

#

my b capital b

buoyant lake
#

OMG

#

Thank you so much

#

it worked

wicked knot
#

yes o7

#

have fun

#

@buoyant lake pls do !close

buoyant lake
#

!close

spark mortarBOT
#
Python help channel closed

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.