Question: i have a file with a on join + random message on ping + anonymous command, when i run the file all commands works great except anonymous command and when i run the same file through visual studio it works
import discord
from discord.ext import commands
from discord.ext.commands import BucketType, cooldown
from discord.ext.commands import CommandOnCooldown, cooldown, BucketType
import random
import asyncio
intents = discord.Intents.all()
intents = intents.all()
bot = commands.Bot(command_prefix='!', intents=intents)
extraid = 1054620224277712936
chill = 765432932713627699
jirve = 852491970999222292
jenny = 986225395667988490
amox = 1103961345533157376
sundri = 1117409456737767515
group_good_msg = [jenny , amox , sundri]
welcome_channel_id = 1133740161197420615
specific_role_id = 933319340470722590 # Replace with the ID of the specific role
welcomemsg = ["aapka hi intezaar tha" , " kaise aana hua " , "padhariye " , "haveli me aapka swagat hai " , " aap aaye bahar aai", " <:ha_bhai:1209489897090588723> Oye tumm ha tum, aa gye, bhot jldi aaye", "<:blusheyebrows:1124649554248208394> kiske intezaar me idhar udhar ghum rhe", "<:hehe_boi:1124648923580092416> thoda idhar bhi aaoooo"]
extrapingmsg = ["kar li chull puri" , "sudharja" , "kya h " , "tera kuch nahi ho sakta" , "GM" , "ghar me bhai baap nahi h kya"]
nicemsg = ["kissi?" , "aise na karo ,kuch kuch hota h" , "hai "]
normalmsg = ["kya takleef h in jannab ko", "hai" , "kaisi hai" , "soja" , "ziddi murga h kya <:kya_bola:1190187079095824505> "]
msgall = ["na manbe?" , "zindgi se pyar nahi h tujhe?" , "ruk mantra marta hu tere pe abhi"]
chupcount = 1
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, CommandOnCooldown):
trigger_message = await ctx.reply(f" Badi jaldi h tereko anjangiri karne ki, chal time khoti mat kar **{error.retry_after/60 :.2f}** minute baad aaio naha dho ke.")
await asyncio.sleep(6)
await ctx.message.delete()
await trigger_message.delete()
else:
pass
@bot.command()
@commands.cooldown(1, 3*60*60, BucketType.user )
async def chupchap(ctx, * , args):
global chupcount
modchannel = discord.utils.get(ctx.guild.channels , id = 1225836301992071239 ) # mod channel jaha anonymus ka message jayega
chupchannel = discord.utils.get(ctx.guild.channels, id = 1225814936249172009) # anonymus channel
chupembed = discord.Embed (title = " anjan insan ne kaha " , description = args, color=random.randint(0, 0xffffff) , timestamp = ctx.message.created_at )
chupembed.set_footer(text = f"anjan vyakti no. **{chupcount}**")
await chupchannel.send(embed = chupembed)
await modchannel.send(f" command used by = {ctx.author.mention} ( {ctx.author} )\n message = {args}")
chupcount += 1
@bot.event
async def on_ready():
status_random = random.choice["Haveli me Havan","With POM POM","With purple ki bandi", "in andheri nagri"]
while True:
print(f'Logged on as {bot.user}!')
await bot.change_presence(status=discord.Status.online, activity=discord.Game(status_random))
await asyncio.sleep(10*60)
@bot.event
async def on_member_join(member):
welcome_channel = bot.get_channel(welcome_channel_id)
if member.id == extraid:
await welcome_channel.send(f"{member.mention} aa gaya extra")
else:
await welcome_channel.send(f" {member.mention} {random.choice(welcomemsg)} ")
@bot.event
async def on_message(message):
if message.author.bot:
return
if bot.user.mentioned_in(message) and message.mention_everyone is False:
specific_role_id = 933319340470722590 # Replace with the ID of the specific role
if message.author.id == extraid or message.author.id == chill or message.author.id == jirve:
response = random.choice(extrapingmsg)
await message.reply(response)
elif message.author.id in group_good_msg:
response = random.choice(nicemsg)
await message.reply(response)
# Check if the user has a specific role
else :
specific_role = discord.utils.get(message.author.roles, id=specific_role_id)
if specific_role is not None:
# Reply with a specific message
response_normal = random.choice(normalmsg)
await message.reply(response_normal)
else:
response_all = random.choice(msgall)
await message.reply(response_all)
await bot.process_commands(message)
else:
pass
bot.run(os.environ["haveli"])