#๐ how to get vc by id
31 messages ยท Page 1 of 1 (latest)
@thorny vapor
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.
to use bot.get_channel, it must be stored in the bot cache which is unreliable. instead try to use guild.get_channel with a guild object either from ctx.guild or something similar
this is a test that runs every 10s so i dont have ctx or anything i can get the guild id if get guild works better
so it's a task loop?
not quite it uses a module that works only on main so i got no idea how to do this
bot=commands.Bot(command_prefix=".",intents=discord.Intents.all())
def check(t):
with mcrcon.MCRcon(HOST,PWD,PORT) as server:
while True:
members=bot.get_channel(1226117248154861572).members
names=[member.nick.lower() for member in members if member.nick]
print("ran")
players=server.command("list")
players=players.split(": ")[1].split(", ")
print(players)
for player in players:
if player.lower() not in names:
server.command(f"kick {player} Go to Mc server voice chat")
time.sleep(t)
check(10)
bot.run("
now that i see i dont even run the bot but how the hell would i do this?
using bot.get_guild would be better since it's not just stored in cache
the giuld is None prob bc the bot aint running but how do i run the bot and run the loop on main at once?
i have to go so its hard to test from my phone but ill try test from now but i can
the issue is that python only allows one thread per program
unless i am being dumb
you can only run one loop at a time
I would just turn the check function into a task loop
Nah u can start new threads just the module i use mcrcon works only on main thread
*by default
So if i do it as a task loop u say it might work?
Also my other idea would have been to rename threads so it thinks it runs on main
that is slightly cursed
Ok good bye
!solved
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.