Hi I recently tested the DM user command in Discord.py rewrite version and forgot to use the delete_after parameter now my DM is filled with Bot message spam how do I make my bot to delete it's own message.
I believe you can do:
send = await ctx.send("test message")
and later, to delete the message:
await send.delete()
This would obviously change because you're doing a DM and not a direct message to a server, but the logic to delete said message is the same.
Related
Ok, so I want to know how to make a bot send a message to the user who boosted the server. So like for instance somebody boosted the server and the bot sent them a message. The following is an example of what I'm thinking.
Client.event()
async def on_boost():
booster.send(message)
#client.event
async def on_message(message):
if "MessageType.premium_guild" in str(message.type):
await message.channel.send("Thanks for server boost")
use this
I left a short message because I am not good at English. I'm sorry if
I offended you. If you leave a comment, I'll answer it.
Normally when someone boosts, a message is put into the discord service channel of a guild. I assume that you can have an if statement in an on_message event that will trigger if a message is in the format of an boost message + it's author is either the server or None
I have a bot with event scopes app_mention and messages.im. It also has OAuth scopes app_mentions.read, channels.history, chat.write, groups.history, and im.history.
If I # mention my bot in a public channel, a thread off of a public channel, or directly message my bot I get an event. But if I'm in a private message with someone else and # mention my bot, I don't get any events from the #mention.
What is the correct event scope to enable to get the event?
you can't unfortuantly. app_mention only works in conversations the bot would have access to. You would need each user to directly give you access to im history and monitor every message event for a mention of the bot itself (probably either some regex or similar to look for the <#bot_name>.
I know there was a link_names part of the json object being sent for message events but you'd still need to check the message body to make sure its your bot being mentioned and not another user
I have deployed my bot on teams channel.
I would like to send a welcome message to a new user even before user sends a message to the bot.
can we achieve this for teams channel?
If yes, which event can be used to get that user is accessing bot for the first time.
You can use the ConversationUpdate event ActivityTypes.ConversationUpdate // in c#
When a bot is installed, your bot receives a conversationUpdate event. You can then send a proactive message to the user. Could you please try sending a proactive message and let us know if you face any issues?
The conversationUpdate event with the membersAdded object in the payload is sent when either a bot is added to a team or a new user is added to a team where a bot has been added. It is always a good practice to send a welcome message introducing the bot to all the users. Ensure that your bot responds to the conversationUpdate message, with the teamsAddMembers eventType in the channelData object. Also, keep in mind that the memberAdded ID is the bot's App ID itself, because the same event is sent when a user is added to a team.
Hope this helps.
When a Microsoft-teams bot is added to an existing message on a channel, by editing the message, would it be possible to notify the bot about the message?
I tried this scenario and looks like bot is not receiving any events for such cases. Is there any interface or mechanism available to notify the bot about the message?
When you edit a Teams message and add any # mention - whether it's to a user or a bot - it doesn't generate new notifications. This has been a gap ever since we added the ability to edit messages.
I have set up a slack bot using slack-api and the real-time-messaging api.
Here is the abbreviated setup:
client.on :message do |data|
d {data}
bot_response = BotResponse.get_bot_response(data['text'], "session_slack")
Slack.chat_postMessage channel: data['user'], text: "#{bot_response}"
end
client.start
With this version of the postMessage, the response comes from Slackbot, not my bot (named kaya).
Goal: I want to respond to come as a DM from the bot it was sent to.
When I change the channel to data['channel'], the response comes as DM from my bot kaya, but gets into an endless loop.
How do I have a non-endless loop DM response?
NOTE:
I think I see how it is happening: by selecting the bot as the "channel" the bot is responding to it's own response back to me, as if it were another user talking into the "bot's" channel. But I can't tell how else to have the response come from my bot, not slackbot.
I believe you need to include the username parameter set to the bot name per the api: https://api.slack.com/methods/chat.postMessage, or you need the as_user option.
This mixes the Web and the RealTime Messaging API. You get a message from the RealTime Messaging API then you are using the Web API to post back. The answer of including as_user: true is correct, but you should instead use the RTM API to send the message back.
Try https://github.com/dblock/slack-ruby-client instead that cleanly separates the two. Sending a message back as the bot looks like this:
client.message channel: data['channel'], text: "Hi <##{data['user']}>!"
To avoid DM loops, make sure you're not responding to commands that you emit. There're other ways, like ignoring bot messages, but it's not as reliable.