webhook url is not copyable which is made by bot - discord

Problem
I can't copy webhook URL from discord client, which is made by bot.
The Copy Webhook URL button is disabled.
What I want to know
How to make the Copy Webhook URL button not disabled which is made by bot
The reason if the URL of webhook is not copyable which is made by bot
What happened
I made a webhook using discord.js by this code:
const target: TextChannel = client.channels.cache.get('CHANNEL_ID') as TextChannel;
const result = await target.createWebhook('webhook made by bot')
and webhook is created correctly, but I can't copy URL from discord client.
To be precise, I can't click on the Copy Webhook URL button. Its disabled.
Of course, I can get URL from result of createWebhook or by fetching webhook info, but I want to allow people who uses the discord client to copy webhook URL easily.
What I inspected
I tried to look into information of webhooks to see difference between webhooks made by human and bot:
this is info of it made by human
'webhook made by my hand' => Webhook {
name: 'Spidey Bot',
avatar: null,
id: 'id',
type: 'Incoming',
guildID: 'guildid',
channelID: 'channelid',
owner: undefined
}
and this is from bot
'webhook made by bot' => Webhook {
name: 'webhook made by bot',
avatar: null,
id: 'id',
type: 'Incoming',
guildID: 'guildid',
channelID: 'channelid',
owner: ClientUser {
id: 'id_of_bot',
system: null,
locale: null,
flags: null,
username: 'botbotbot',
bot: true,
discriminator: 'XXXX',
avatar: null,
lastMessageID: null,
lastMessageChannelID: null,
verified: true,
mfaEnabled: false,
_typing: Map(0) {}
}
}
It looks like there is flag bot to identify whether the webhook is made by bot or other.
Can I solve this problem by editing this option?
Can I make it change?

How to make the Copy Webhook URL button not disabled which is made by bot
From what I know, this is not possible. After reading through Discord Developer portal, it doesn't look like the Discord API allows you to make significant changes to the webhooks apart from name, avatar and channel_id.
You won't be able to create a normal webhook (human made) through your bot without it being considered self-botting, which is of course prohibited.
The reason if the URL of webhook is not copyable which is made by bot
It is a special type of webhook, an application-owned webhook, managed by an application (e.g. your discord bot). Purpose of such webhook isn't to be used by regular users.
One of the differences between normal and application-owned webhooks is that application-owned webhooks allow you to send message components. So unless you are aiming for that, you should be fine with normal webhook.
If your goal is to automatically create webhooks in multiple guilds as part of your bot's features and an application-owned webhook is an absolute need (there is no other way). I would make a command, that will show you a list of webhooks in current channel with their URLs for your users to use (of course with permission checking and privacy, etc.).

Related

Discord bot profile application

How to create an application on the user's profile with pycord(https://i.stack.imgur.com/vmt03.jpg)](https://i.stack.imgur.com/kMRc7.jpg)
I searched but did not find anything
Actually this is happens only mobile view.
What is causing this is "user.command".
#bot.user_command(name="name")
async def name(ctx, user: discord.Member):
await ctx.respond(user.name)

I'm wondering how this is possible? Discord bot

I recently receive a 2 message in discord with invite link to server I received it from bot who doesn't share the same server with me or anything
How this is possible, I find some py codes but only work if the user and bot share same server
from discord.ext.commands import Bot, Greedy
from discord import User
bot = Bot(command_prefix='!')
#bot.command()
async def pm(ctx, users: Greedy[User], *, message):
for user in users:
await user.send(message)
bot.run("TOKEN")
How can I make one send messages to list of IDs not in same server?
Maybe the bot left the server after he sent the invite to everyone.
You could check if one of the bots was in the servers in the audit-log.
you could either get the user by id with the guild.get_member(id). That requires the user to be on that specific guild you try to get the user.
Or you can use bot.get_user(id) / await bot.fetch_user(id). There the bot tries to get the user. If found you can do sth with it else it will return None or raises the command Error UserNotFound.
A bot that has no mutal guild with a specific user cannot send a dm to them.
Also what purpuse is it to send dms to multiple users from a list?
Keep in mind that its against the Discord TOS to mass dm users without permissions. If they did not opt in sth to get dms I would not send random dms do multiple users.

How to send message to a specific user from discord bot using discord.js

I want to send a message from my discord bot to a specific user like myself using my discord id.
I have tried the following code where my client object is named as bot:
bot.users.get("My Id copied from discord").send("Message to Send");
but it gives the following error in the terminal:
bot.users.get is not a function
Please help me in resolving this error.
Thank you
Since discord.js v12 you need to use cache to access the users collection
bot.users.cache.get('ID').send('hello')
You need to use users.fetch() instead since the user might not be cached
const user = await bot.users.fetch('ID')
user.send('hello')

MS Teams Get Roster returns "The bot is not part of the conversation roster."

I am trying to fetch the MS Teams roaster / user profile.
Below are the sequence of Postman calls I am making:
Generated Access Token:
https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token
Generated User Access Token:
https://login.microsoftonline.com/{{TenantId}}/oauth2/v2.0/token Get
My Joined Team: https://graph.microsoft.com/v1.0/me/joinedTeams
Get Internal Team
Id:https://graph.microsoft.com/v1.0/teams/{{TeamId}}/channels
Fetch Roster/user
profile:https://{{ServiceUrl}}/v3/conversations/{{tId}}/members/
Everything was working fine, but today I am getting 403 forbidden error
{
"error": {
"code": "BotNotInConversationRoster",
"message": "The bot is not part of the conversation roster."
}
}
Please note that I am able to communicate with the bot.
Below are the permissions that I have provided for delegate and application
Directory.Read.All
Group.Read.All
Group.ReadWrite.All
User.Read
User.Read.All
User.ReadBasic.All
Any suggestions to fix the same?
Notice that your last call, the one to "serviceurl", is NOT part of the Graph, obviously. As a result, it's authentication is different. In this case, Teams is authenticating it as a bot, and it needs certain rights. For instance, the bot MUST be installed to the Team in question in order to get the roster for that Team. You say it was working before - is that in the same Team? If not, the bot needs to be added to that Team. If "yes", then perhaps the bot was removed from the Team by someone?
You must install your bot as an app in a team before you can call this API. Sending it messages via a webhook does not count. It must be an app installed in the team. Because the bot is retrieving personal information, it needs to be added to that context before the API will work.
See:
Bot Overview - https://learn.microsoft.com/en-us/microsoftteams/platform/bots/what-are-bots
Bot Context - https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/get-teams-context?tabs=dotnet

How to make buttons work on a messenger chatbot?

We are developing a Facebook Messenger chatbot but we are having issues integrating our chatbot with Facebook Messenger.
When, during a chat, the user sends a text message our webhook receives the data and does all the processing accordingly.
But when we send the user a menu with buttons and the user clicks the buttons instead of typing a message our webhook doesn’t receive the payload ar any other data that we were supposed to receive.
When the user starts a conversation with our chatbot we send them the following message:
{
"recipient":{
"id":"2492007720844646"
},
"message":{
"attachment":{
"type":"template",
"payload":{
"template_type":"button",
"text”:”What do you prefer?”,
"buttons":[
{
"type":"postback",
"title”:”Blue",
"payload":"{'function':{'name':'color_blue'}}"
},
{
"type":"postback",
"title”:”Red”,
"payload":"color_red"
}
]
}
}
}
}
If the user clicks the button titled “Blue” our webhook doesn’t receive the payload “color blue”. On the other hand, if the user types the message “color blue” our webhook receives it without any problem.
If I try to simulate the problem using my own Facebook user, which is the app administrator, when I click the button the webhook receives the payload “color blue” without any problem but when any other user tries the same thing then our webhook won’t receive the payload. I suspect it is a problem with my app’s permission but I’ve already added to the app all permissions I think it needs.
Click here to see an image with an example of what we are trying to do
Note that the options on the left are provided automatically by the bot and the user just need to click on those options to keep the conversation going. There is no need for the user to type anything. Our problem is that when the user clicks on the options in the left we don't receive that message and therefore we can't do anything.
I couldn’t find any documentation related to this kind of behavior, can someone help me, please?
Any help will be very welcomed.
Thanks and please let me know if you need any further information.

Resources