i have a discord bot written in python and it uses a users discord auth token. When th program is running it wont send any mobile notifications because it makes discord think im online and wont go afk for the afk timer to kick on. Is there a way to use the auth token and not have discord think im logged in? or is there a way to make discord think the user is afk? any help would be gratly appreciated!!
Use Client.change_presence()
await bot.change_presence(status = discord.Status.idle)
Here are the different kinds of Status available.
Related
I have two working discord bots and a test server. I want my first bot to add the second bot to the test server. How would I go about this? I have researched it and found nothing. Any help would be appreciated. Thanks!
This isn’t possible, bots can’t run other bots cmds or add other bots to a server.
Just started to implement a simple bot for Discord.
All goes well but I just cannot find an info on how to detect when bot was authorized on some server.
I mean when somebody use OAuth2 link provided in Discord developer portal to add my bot to a server.
How can I get ID of this server? Is there some event for that?
Thanks.
You can detect the event when your bot joins a guild using the on_guild_join() event: (ref: https://discordpy.readthedocs.io/en/stable/api.html#discord.Client.guilds)
#client.event
def on_guild_join(guild):
# Do something
You can always get the list of guilds your bot is in by using client.guilds (ref: https://discordpy.readthedocs.io/en/stable/api.html#discord.Client.guilds) Note that you require permissions to access this event.
I was looking for a way if you can find all the members from a particular server in discord to let's say remove them from your server as they can be from your opponents' server lurking around. If there is a way I want to create a discord bot for it. Any help related to it will be appreciated.
Yes there is, but this would require that the user authorizes your application. It would work something like this:
Your bot has some sort of webserver listening
Your bot gives them a link
They click the link, discord asks them to authorize your bot
Discord redirects them to your webserver with a token in the parameters
Using that token, you can access info such as what guilds they are in.
This is easiest if you already have a bot dashboard, but can still be achieved without one (though you still need a webserver to listen for the callback).
If you have a quart webserver (which is how I would recommend doing it) then take a look at this: https://github.com/jnawk/Quart-Discord
Edit: Also note that, if your bot is in this other guild, you can do a simple check, like this:
g = bot.get_guild(guild_id)
await g.chunk()
if member in g.members:
# ban them
I want to make my Discord bot able to respond to another bot's commands. So the other bots can use my bot. What can I do to do this for specific commands? What should I add to this? Thanks for all your help.
#bot.command()
async def dothat(ctx):
await ctx.send("!blabla")
this is not possible on discord.py only in discord.js and discord.jda
Other bots will probably block bots from contacting it, as it's policy on several discord listing sites (such as top.gg). By default however, other bots can contact other bots.
Bots can detect whether its a bot contacting it through the use of
ctx.message.author.bot
which is a boolean that is true when the author of the message is a bot.
I'm writting a Discord bot with Discord.py. What I am trying to write is a bot that grabs a picture from reddit, saves the image id in Discord and posts the image to twitter. I use Discord because I am hosting the bot with Heroku and it does not allow to save images or text files. I thought it was a clever way to keep track of the images that the bot picks by posting the images id in a private Discord server
My problem is that every time Heroku restarts the bot I need to post a command on Discord to make it start again. I think there should be some way to avoid this but after reading the Discord.py docs I could not find any solution that allows to read and print comments on Discord without the use of events that require manual inputs.
If you bind your code to a command, obviously you always need to call this command after the bot restartet.
Use the on_ready() event to call your code everytime your bot starts:
#client.event
async def on_ready():
# CODE
channel = await client.fetch_channel(YOUR_CHANNEL_ID)
await channel.send(OUTPUT)