Posts

Showing posts with the label discord

How to get username from client id after the user has left the guild

How to get username from client id after the user has left the guild I have: bot.users.get(id) but when user leave the server an error pops up. Can I get the username with the ID differently if the user is not on the server? I have statistics. I am downloading from the User Id database and I am replacing the ID with its name, but if the user has left the server, there is an error because there is no such user. What can I do? How do you plan on getting the id if the user is not on the server anymore. Input? – Rishav Jun 29 at 10:53 1 Answer 1 Since client.users stores only cached users, you won't be able to retrieve their username in a reliable way from there. client.users DISCLAIMER : This method is really inefficient, but discord.js hasn't bee...

StreamPlayer “after” function isn't being called

StreamPlayer “after” function isn't being called I am creating a discord bot that can play music but I'm a bit stuck because when the bot finishes playing music is should leave the current voice channel. However this isn't happening, instead my after function vc.disconnect isn't being called at all though I've followed the instructions on the FAQ page. after vc.disconnect vc = await bot.join_voice_channel(ctx.message.author.voice_channel) player = await vc.create_ytdl_player(arg.split(' ')[1], after=vc.disconnect) player.start() If I change the function to after=lambda: print("exit") the output comes after the ytfl window closes. – godith 320 Jun 30 at 7:18 after=lambda: print("exit") What happens if you do the same thing: after=lambda: vc...

How to use commands only when a current command is triggered?

How to use commands only when a current command is triggered? This question might be complicated and my brain can't really explain it well so please bare with this crappy explanation, My question, When you trigger a command for example .start it will start let's say a text based game, of course you would have the commands to be able to actually play the game however my concern is people can still trigger the ingame commands without needing to start the game for example . if message.content.startswith("/play"): #Here is the play command where you execute the game to start await client.send_message(message.channel, "Welcome to the game!") if message.content.startswith("/examine): await client.send_message(message.channel, "You examined the rock and well, got a rock!") #In-Game commands/movements What i'm saying is, is there a way of only being able to use the in-game commands only when the game itself is act...