JDA - slash command event? - discord

is it possible to execute an event when user is using slash command to other bot? Example: something as counter for user's executed commands. (fe. user is typing /ban [...] (in slash command) and it will be executed by other bot and mine (for just counting). I hope you understood me good.

No, that's not possible since the slash command is passed directly to the corresponding bot without other users or bots having the possibility to access or receive it.
If both bots are yours you might be able to implement a notification that is sent by one bot to another.
Another possibility is reading from the audit log of the guild, but iirc it's not failproof and might be hard to implement correctly.

Related

Can I create an app or a bot in discord that send messages as it was me?

I want an app/bot that reads the last message that were sent to a specific channel on a server that I participate and depending on the text I want to send a message to that same channel. The thing is, I want to do it in my name, not using a bot id. I know that you can create a bot using your own name and avatar but what I really want is to send a message using my own account. Is that possible? Could not find anything like that in the docs, maybe a missed something?
I do not think you are even allowed to do this so I doubt the discord API would have support for this
Discord Guidelines
"Do not use self-bots or user-bots. Each account must be associated with a human, not a bot. Self-bots put strain on Discord’s infrastructure and our ability to run our services. For more information, you can read our Developer Policies"
However, if you really wanted to do this you could use a macro at the risk of getting your account banned by discord if they found out. You could create a macro in python using the pyautogui module.

Automatically send messages as current user in discord

I'm new to discord.js but I would like to understand. Is it possible to achieve a functionality that would send message as my current user?
I mean for example I'm normal user on a discord server and I want to send randomly some jokes every day once. But this should happen from my current user, which has the discord name.
I know I can have a bot created and registered, but this is another approach I think.
My questions are: Is this achievable with discord.js or not really? Is this functionality achiavable at all? And where do I begin?
Thanks for any help.
It is possible. It's just like making a discord BOT. But rather than making a bot application and using its token, you just use YOUR token.
This is purely for educational purposes only, and you shouldn't use it for anything else. Everything is possible, especially with discord.js.
What you are describing is a "self-bot", and is against the Terms of Service. As such, it is not supported.
Discord has made an announcement regarding self-bots before.
Here is a relevant excerpt:
Automating normal user accounts (generally called "self-bots") outside
of the OAuth2/bot API is forbidden, and can result in an account
termination if found.

Discord.py bot is unable to do something yet another bot with same code can

So my bot able to go through channels and clear specific messages, but now it can't do it because of missing access. I made an another bot and fired up the same code. And it worked. How is this possible? I don't think there is a problem with the code, but with the bot itself.
Ensure that your bot has permissions set in discord.com/developers/applications - Under the bot tab make sure you've checked all the appropriate boxes. If you are truly running identical code that is most likely your issue.

Run One instance of Discord bot per server, So bot doesn't turn on on every server

So my code activates a listener which will then just simply return the message to the user. However, once the listener is activated, it will be GLOBALLY activated, so all servers with this bot will be affected. How can i create one instance of the bot per server.
The only way to run multiple instances of a bot would be to copy the bot's code and use it in several other bots. You'd need to create several bot applications/users from the developers page and generate tokens for each bot.
It's a bit sketchy and not recommended so I'd be careful with what you're trying to achieve here.

Facebook Messenger bot: 1st interaction different to subsequent for same command?

Does anyone know if it's possible to return a different message etc to the chat user if it's the very first time they are interacting with the bot?
For instance, if a user says "hello" (or anything) for the very first time, the bot might respond with, "Hello there!"
If a user says hello some time later, the bot might respond with "Hello, again!"
Looking through the developer docs I'm struggling to find an answer: https://developers.facebook.com/docs/messenger-platform
For context, I'm also using the https://api.ai service.
One way to accomplish this is to set up a "get started" button:
https://developers.facebook.com/docs/messenger-platform/messenger-profile/get-started-button
This might also be helpful:
https://developers.facebook.com/docs/messenger-platform/messenger-profile/greeting-text
(But I haven't used it myself, so I'm not sure what it does.)
Also, as already mentioned, you can store user data in your own database, and send a greeting message if you can't find the user there already.
This would currently not be possible with API.ai out of the box, you'd have to build a custom webhook that would save the user id to database and check it on new session.
As a (very) hacky workaround you could try outputting a context after the first hello and each and every other intent you use inputs and outputs that context, essentially remembering the user has talked to the bot via a 'permanent' context.

Resources