My selfbot only responded to me and not other users - python

I run the code and send "xd", selfbot replies "lmao", but if another user writes "xd", selfbot does not reply "lmao", What do I do to make it respond to any user or bot?
import discord
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio
#TOKEN
TOKEN = "u token"
client = discord.Client()
b = Bot(command_prefix = "x")
#b.event
async def on_ready():
print("I ready")
#b.event
async def on_message(message):
if message.content == "xd":
await message.channel.send("lmao")
b.run(TOKEN, bot = False)

you cant do on_message for commands anymore so i recomand you do something like this
#b.command()
async def xd(ctx):
await ctx.send("lmao")
self botting is agaist discord TOS

Related

The discord bot is not working. He does not respond to commands

I'm making a bot for a discord server. He doesn't respond to messages, what should I do?
import discord
from discord.ext import commands
client = commands.Bot( command_prefix= "!")
#client.event
async def on_ready():
print('Bot active')
async def hello(ctx):
author = ctx.message.author
await ctx.send('Привет, как поживаешь')
#client.command()
async def send_a( ctx ):
await ctx.author.send("Привет")
token = "here my id"
client.run(token)
He must send messages to the chat, as well as private messages to the server participants

discord python bot isn't replying to commands

my discord bot isn't replying to commands does anyone know why? i also get an error that says discord.gateway: Shard ID None has connected to Gateway
token = 'mytoken'
import discord
client = discord.Client(intents=discord.Intents.default())
#client.event
async def on_ready():
print('we are logged in as {0.user}'.format(client))
#client.event
async def on_message(message):
if message.author == client:
return
if message.content.startswith('$info'):
message.channel.send(f'> i am a bot currently being developed by agent')
client.run(token)
You should use a bot instead of a client, and don't forget to await async functions.
try this:
import discord
from discord.ext import commands
token = 'mytoken'
bot = commands.Bot(command_prefix='$')
#bot.event
async def on_ready():
print('Ready!')
#bot.command()
async def info(ctx):
await ctx.send('> i am a bot currently being developed by agent')
bot.run(token)
now try $info with the bot running.
Try to use discord.ext.commands instead of discord.client
token = 'mytoken'
import discord
from discord.ext import commands
client = commands.Bot(intents=discord.Intents.default())
#client.event
async def on_ready():
print('we are logged in as {0.user}'.format(client))
#client.event
async def on_message(message):
if message.author == client:
return
if message.content.startswith('$info'):
message.channel.send(f'> i am a bot currently being developed by agent')
bot.process_commands(message)
client.run(token)

Your message was not delivered. Discord bot

I'm making a discord bot. when I send commands on the server from my account with the owner role, then everything is OK, it is executed.
photo_1
If I switch to another account that has the everyone role, then the bot stupidly does not react.
photo_2
here is a piece of code:
import discord
from discord.ext import commands
from dislash import InteractionClient, Option, OptionType
bot = commands.Bot(command_prefix='!')
inter_client = InteractionClient(bot)
#bot.event
async def on_ready():
print('Bot is launch!')
#inter_client.slash_command(description="Says Hello")
async def hello(ctx):
await ctx.respond(content='asfd', ephemeral=True)
bot.run(token)

discord bot sends infinite messages regardless of user input

I'm trying to make a discord bot respond when someone makes laughing remarks but it infinitely sends gifs whenever someone types anything
code is as follows
import os
import discord
import random
from discord.ext import commands
import keep_alive
Bot_Token = os.environ['Bot_Token']
bot = discord.Client()
#bot.event
async def on_ready():
guild_count = 0
for guild in bot.guilds:
print(f"- {guild.id} (name: {guild.name})")
guild_count = guild_count + 1
print("AGOP_Bot is in " + str(guild_count) + " guilds.")
#bot.event
async def on_message(message):
if message.content == "AGOP~hello":
await message.channel.send("https://c.tenor.com/tTXwGpHrqUcAAAAC/summoned.gif")
if message.content == "Lmao" or "Lol" or "lmao" or "lol" and message.author.id != bot_id:
response_funny = ["https://c.tenor.com/mUAgLfICUC0AAAAC/i-didnt-get-the-joke-abish-mathew.gif","https://c.tenor.com/zdoxFdx2wZQAAAAd/not-funny-joke.gif","https://i.pinimg.com/originals/f5/53/97/f55397a7de1c82b37d6d62e655a0e915.gif","https://jutsume.com/images2/2022/04/16/is-this-some-peasant-joke-meme.png","https://c.tenor.com/FnASqUdvJH4AAAAC/whats-so-funny-john.gif"]
await message.channel.send(random.choice(response_funny))
bot.run(Bot_Token)
keep_alive.py
import os
import discord
import random
from discord.ext import commands
# import keep_alive
Bot_Token = os.environ['Bot_Token']
bot = discord.Client()
...
#bot.event
async def on_message(message):
if message.content == "AGOP~hello":
await message.channel.send("https://c.tenor.com/tTXwGpHrqUcAAAAC/summoned.gif")
if message.content in ("Lmao" or "Lol" or "lmao" or "lol") and message.author.id != bot.user:
response_funny = ["https://c.tenor.com/mUAgLfICUC0AAAAC/i-didnt-get-the-joke-abish-mathew.gif","https://c.tenor.com/zdoxFdx2wZQAAAAd/not-funny-joke.gif","https://i.pinimg.com/originals/f5/53/97/f55397a7de1c82b37d6d62e655a0e915.gif","https://jutsume.com/images2/2022/04/16/is-this-some-peasant-joke-meme.png","https://c.tenor.com/FnASqUdvJH4AAAAC/whats-so-funny-john.gif"]
await message.channel.send(random.choice(response_funny))
bot.run(Bot_Token)
# keep_alive.py
In addition to some formatting, I changed some of the variables for the API calls. I commented out the keep_alive.py as I assume you are using that to keep your code hosted on Repl.it or something, and you can just comment it back in. I was also able to get this code to work with my bot and execute as you want.

How do i make my discord.py bot react to all images sent in a channel

I am using this code but it crashes when i launch it, i want the bot to react with the custom emoji from my server (:okay:) to every image sent in a specific channel. Anyone knows why?
import discord
from discord.ext import commands
from discord.ext.commands import Bot
import asyncio
bot = commands.Bot(command_prefix = '//')
#bot.event
async def on_ready():
print ("I have awoken")
async def react(message):
custom_emojis = [
"<:okay:942697477507801098>"
]
guild_emoji_names = [str(guild_emoji) for guild_emoji in message.guild.emojis]
for emoji in custom_emojis:
#print(emoji, guild_emoji_names)
#print(emoji in guild_emoji_names)
if emoji in guild_emoji_names:
await message.add_reaction(emoji)
#bot.event
async def on_message(message):
if message.channel.id == 929345014205653014: and \
if message.attachment:
await react(message)
You need to have the message_content intent enabled to receive message attachments.
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix = '//', intents=intents)
There is no attachment attribute in the Message class it's, attachments instead. Also, this is how you use and operator in an if statement:
if message.channel.id == 929345014205653014 and message.attachments:

Categories

Resources