I'm making an bot/remote terminal with Discord.py, like going to discord and sending "!remote Some Batch command" and the script executes in the computer with the bot running. how do i do that?
Alternative way to describe:
Take the input from a discord user (me) and use the arguments (!command ARGUMENT ARGUMENT2) as commands, to be executed in the host machine (the machine with the code running)
I didnt try anything, but i think something like %1 (batch) would work.
Related
I am writing discord bot on python (discord.py). This bot for many servers and I want to make cooldown system. This looks like this:
User uses command on the first server and if he uses it again, bot will tell user that command on cooldown, but if user will go to the second server, command will work without cooldown that is on the first server.
You can use
#commands.cooldown(1, 86400, commands.BucketType.user)
First number is how many times someone can run the command without triggering the cooldown.
Second one is how long the cooldown is in seconds.
BucketType tells the bot its per user, there are different bucket types, for example for roles, server and so on.
Refer to the dpy docs.
As far as I know bucket type user is server dependent. So it should work fine.
A simple command cooldown will do it!
#commands.cooldown(1, 20, commands.BucketType.user)
This does work, but be carful. Restarting your bot removes the cooldown.
I've been hosting a discord bot on an online IDE but it happens to disconnect from the API after a while. The code on the IDE continues to run, but on discord, it is unable to respond to commands and essentially the entire bot is completely offline, while a running code is being executed. Even more suprising is a background task that I have assigned to run every minute continues to do it's job ( which is to edit a embed in a server with new information ). I've been going through the documentation and about the gateway kinda stuff but I'm utterly confused. It states that disconnections are regular but never teaches me how to actually connect again rather some snippets of JSON data. Documentation here : https://discord.com/developers/docs/topics/gateway#gateway-intents
I'm a bit new to this stuff but the documentation clearly doesn't talk anything about the way to connect to the gateway, and what to do during a op7 reconnect. How would I be able to incorperate this reconnection thing with my discord bot also?
how can I run the telegram auto message bot when I turn off my computer with the API I made with python?
Otherwise, it exits the terminal and the bot closes automatically.
Are you asking why when your computer turns off, and the python file stops running, the bot no longer functions?
You would need to have either a server or another device to run it then, should you wish to turn your computer off
I'm not sure if I misunderstood this or not.
My bot was giving me two outputs or more every time I gave it a command (for example, I said .ping and said the bot's ping twice). I figured out that the problem was the bot was running somewhere else, so I regenerated the token and everything worked fine for a little while until the problem started happening again. I kept regenerating the token and it fixed the problem for a bit. Is there a way I can find where else my bot is running and shut it down there?
If you want to close all running instances of the bot, just use exit().
#commands.is_owner() #make sure no one else uses it
#bot.command()
async def stop_bot(ctx):
exit()
This will close all the instances of the bot.
I’ve been working on a telegram bot and I just managed to design it to handle commands and issue responses to users.
I was able to achieve this successfully and started testing each and every command repeatedly to ensure they work, mind you these are like 6 or 7 commands. Basically user sends the /command and my bot sends feedback and that for like the very first few tries, like it really worked then suddenly it all stopped working.
The welcome message for new group users from the bot the feature still works but the commands aren’t.
I didn’t register all commands with BotFather but they worked anyway regardless so I’m not sure that’s the problem.