So basically, Is there any way to get the ID of the author who kicks my bot. Likewise, on_guild_join triggers when bot joins the guild however, Is there any way to get author id from leave event?
No; the only way to see who kicked a bot is to go into the audit logs and look for a notice that says:
User A kicked Bot A.
Since the bot is outside of the guild, it has no way of accessing audit logs, and therefore cannot see who kicked the bot.
For your second question, also no. The on_guild_remove only takes guild. It therefore cannot see the kicker/banner.
See https://discordpy.readthedocs.io/en/latest/api.html?highlight=on_guild_remove#discord.on_guild_remove
Related
I am trying to obtain the users message that was deleted and post into a logging channel and frankly I am stumped on how to get users message, and Author of messages name. After these two I will make a simple embed posted to a new channel but I cant figure out how to obtain the information. I searched here and only found answers for js but was wondering if there is a JDA answer.
Discord makes it hard to retrieve messages because it may be against the TOS and can get (in worst cases) you or your bot banned/removed. Also, most bots with deleted message logging will not have this feature anymore due to a change in the API in April 2020. I also think the answers for JS libraries were made before the API change.
If you really wanted to have deleted message logging you can have your bot store every message along with message IDs and author usernames. To optimize it a bit you can have different log files for each channel. When onMessageDelete() is called, you can get the logs for the channel and look for the message content and author username corresponding to the given message ID. The reason you have to do this is because this event only gives two things useful things: the message IDs and the channel IDs. If we had getAuthor() or getMessage() deleted message logging would be a breeze because we could just get that data directly.
If you don't want to go through all this hassle, you can use 1lighty's MessageLoggerV2, but client modifications are against the Discord TOS and are generally frowned upon in most cases.
I am new to Microsoft bot framework and have seen the term turncontext many times.
Can some one explain what that actually means and its significance.
eg: turncontext(adapter,activity)
When using a bot, the user and the bot take it in turns to speak. Within the Bot framework a turn is a users incoming activity which the bot responds too. Every message a bot receives from a new user will be in a new turn.
If the user asks a question "What is the weather like today?", the bot may respond with "Where would you like the weather for?". That is all in one turn. The user then responds with "London", this is in a new turn.
The turnContext is the object that gives you access to the information about the current turn from the user. This includes the current message sent by the user among for example. For a full specification see here. It's also used to send messages back to the user, SendActivityAsync is one to do this.
Take a look at this Microsoft article I used as the basic of this answer which goes into way more detail. Also take a look through the Bot Framework Samples and step through the code to learn more about the turnContext.
I have developed a bot in MS Teams and i want to fetch the channel Ids where the bot is installed and can send the messages.
Any ideas how to do this, thanks a lot
You can only really do this when there's an interaction from the user, so for example when the user sends your bot a message. The best time of all, however, is when your bot is actually installed, because then you have it right from the beginning. You use the ConversationUpdate event, as described here.
If it's too late for that (your bot is installed already), then I'm only aware of waiting for the next message - I'm not sure if it's possible to get things like the conversation id another way.
When someone add my bot to their groupchat I am receiving a ConversationUpdate event and I am storing it for future reference. But storing all conversationUpdate events(which I will get when someone add my bot to their chat) of all groupChats has become a problematic. Is their any function for getting the Information about all groupChats that my bot has added to. Like we have a function for listing all Teams channels ex:- TeamsInfo.getChannels(context)
I would be thankful for any help
I'm not aware of any way to do this - the best I could suggest is something like listing conversation members of existing chats, on the graph beta endpoint (https://learn.microsoft.com/en-us/graph/api/conversationmember-list?view=graph-rest-beta&tabs=http). However, that would mean (a) it needs to returns bots as members of the chat, which I'm not sure it does (b) you'd need to basically query EVERY possible group chat in the organisation and (c) you'd need access rights to do that (e.g. application access). So, it certainly sounds like just storing the conversation id upfront on your own would be a better bet.
Recall that you can get the conversation id (if that's what you're looking for) from any event, not just conversationUpdate - even a regular message to your bot from a user in the chat will have the conversation id attached. Also, you've haven't stated what you need the conversation id for. Presumably it's for pro-active messaging, but in that case remember to store the service url as well.
I want to create something in Slack that sends a message (starting by calling someone with '#') to a channel when specific users login. I've checked ifttt and zapier. I also checked the slack api to create something myself, but I couldn't really find anything usefull.
Anyone has any ideas?
Slack does not track user login or logoff in a traditional sense. Instead, users are always always "logged in" and available to receive messages once they have joined a team / channel.
There also is the concept of "presence", which is related, but not the same thing. User presence can change multiple times during a few minutes, e.g. if the user is on a mobile. I am guessing you would not want to send the user your message that often.
Still you can poll the presence information of a user with the API users.getPresence , which could be used to implement a script that polls this information on a regular basis and send your message. You also want to filter out presence changes below a certain duration threshold.
Keep in mind though that the rate limit for API methods is 1 per second. So depending on how many users you have in your workspace there will be a significant delay between the user becoming "present" and your script being able to send the message.
There is a workaround for that to have a google sheet as a database for the users and you can trigger by day once and timestamp it.
So the best trigger is a private message or public and you can use filter when mentioning or signin or signout it depends on the trigger word then you pass the filter since zapier won't count your zaps if you used fiter as a second step.