Hello i need help i am bulding a bot that play music on !play type hi back when u type hi and sen dwelcoms to member so basicly bot has no error in code and no error on start up i discord developer poltar i turn everthing on. So bascily bot is online runing in discord is onlyne but he do not resposn to hi he do no play music and he do not send welcom cards so what shoud i do?
Hey, @gasperpk welcome to the forums!
Can you please provide a link to the repl? This way it is easier for staff and members of the community to help you!
Also see this guide on how to share your code:
Looks like a ratelimit problem based on your description
There are massive errors when you get rate limited, so i don’t think so.
The user never stated that there weren’t any errors, just it wasn’t responding
A bot could be shown as “online” but it could be unable to send messages because it is ratelimited
OP’s many grammar mistakes and spelling mistakes made them hard to understand, but i think this means no error.
OP’s description is definitely hard to understand but “no error in code and no error on start u” probably means that the bot started without any errors which further points to a ratelimit as the bot was running.
This is main.py
import os
import discord
# Define the required intents
intents = discord.Intents.default()
intents.members = True
# Create a new instance of the client with the specified intents
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print(f'Logged in as {client.user.name} ({client.user.id})')
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.lower() == 'hi':
await message.channel.send('hi')
bot_token = os.environ['token']
client.run(bot_token)
Please put three backticks (```) around your code so it is formatted correctly. But here I’ll format it properly for you.
Hmmm, try Intents.all
. And, if you are making a discord bot, please do not use on_message, use ext.commands. Your code for that would be this:
import os
import discord
from discord.ext import commands
# Define the required intents
intents = discord.Intents.all()
# Create a new instance of the client with the specified intents
bot = commands.Bot("mb!", intents=intents) # Prefix mb!
@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name} ({bot.user.id})')
@bot.command()
async def hi(ctx):
await ctx.send('hi')
bot_token = os.environ['token']
bot.run(bot_token)
With that code you can run mb!hi
and get a result.
okay thanks that works so basicly if i delet preffex will still send hi after i send hi
just set it to ""
I guess but that is bad practice.
do you know why this coe for join.py do not work
import discord
import datetime
import os
from discord.ext import commands
# Define the required intents
intents = discord.Intents.default()
intents.members = True
# Create a new instance of the bot with the specified intents
bot = commands.Bot(command_prefix='!', intents=intents)
@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name} ({bot.user.id})')
@bot.event
async def on_member_join(member):
# Get the current time
now = datetime.datetime.now()
# Create the embed message
embed = discord.Embed(title=f"{member.name} joined the server!",
color=discord.Color.green())
embed.set_thumbnail(url=member.avatar_url)
embed.add_field(name="Name:", value=member.name, inline=True)
embed.add_field(name="Joined at:",
value=now.strftime("%m/%d/%Y %I:%M %p"),
inline=True)
channel = bot.get_channel(1096019204966203444)
await channel.send(embed=embed)
# Set up the bot token
my_secret = os.environ['token']
bot.run(my_secret)
Is that code in main.py
or in join.py
? If it’s in join.py
, then replit doesn’t run that code unless you modify the .replit
file.
it is in join.py how i runit
Hey @gasperpk!
Just click the three dots then click “Show hidden files”. Next click on the .replit
file and finally you can change the entrypoint
to whatever file you want to run.
You can also change the second line from run="python main.py"
to run="python join.py"
, though it won’t have an effect for interpreted languages as shown in the comment on line 1.
Also see the docs on how to configure a Repl: https://docs.replit.com/programming-ide/configuring-repl
but i wanna run main.py join.py and music.py at the same time
Where is the link to the Repl? Did you ever send it?
no idk how to creat one
Have you looked at this guide that @dragonhunter1 suggested? It shows you exactly how to find the link to your Repl.