#๐ discord bot that checks vc?
7 messages ยท Page 1 of 1 (latest)
@mellow crane
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.
Closes after a period of inactivity, or when you send !close.
# Event to detect voice state changes
@client.event
async def on_voice_state_update(member, before, after):
global study_activity_flag
# Check if the voice channel is in the desired category
if after.channel and after.channel.category_id == 1189846054003294238:
study_activity_flag = True
elif before.channel and before.channel.category_id == 1189846054003294238:
# Check if anyone is left in any voice channel in the category
for voice_channel in before.channel.category.voice_channels:
if voice_channel.members:
break
else:
study_activity_flag = False
# Function to send embed with ping
async def send_embed_with_ping():
global study_activity_flag
if study_activity_flag:
# Calculate the future time (5 minutes from now)
future_time = datetime.utcnow() + timedelta(minutes=5)
# Format the future time in Discord timestamp format
timestamp = f"<t:{int(future_time.timestamp())}:R>"
# Hexadecimal color code (Example: #dc6bad)
hex_color = "#dc6bad"
color_int = hex_to_int(hex_color)
# Send the embed with ping to the desired channel
channel = client.get_channel(1233681987278078062)
embed = discord.Embed(title="เฑจเง โ๏ฝกห **accountability message !!**",
description=f"`what are you studying on right now??\n \nplease answer `{timestamp}` or you will be kicked from the study call.`",
color=discord.Color(color_int))
await channel.send("<@&1233476419808657439>", embed=embed)
this is just a snippet btw
of the part that im not sure whether it works
@mellow crane
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.
๐ discord bot that checks vc?