Discord bot get user id by only name - discord

So I'm currently making a bot that should dm users who entered their discord name(example#0000) outside of discord, I now need the bot to convert their names into their Id's, in order to dm them.
Is that even possible?
For clarification, the bot is not on the same server as the users and has never interacted with them.

No, it’s not possible to get a User/Member instance by name if you don’t share a guild, the only possible way would be to fetch it from the API using an ID
user = await bot.fetch_user(123345567901)

Related

Can a Discord Bot Invite Other Bots?

Can a Discord bot invite other bots? Can Discord bots automatically accept invites they get in a DM? How would one go about doing this?
Is it possible to make a bot that accepts invites, or do bots have to be invited themselves.
No, this is not possible.
Users must invite the bot themselves to join the server. I'm not sure I understand the use case here, because users can get similar functionality by simply inviting the bot.
To generate an invite link, start by heading to the Discord developer portal.
Then, head to the "OAuth2" tab:
Scroll down and find the URL generator. You'll need to select the following:
Generally you'll want to calculate the permissions, but this will work for now.
Now, if you want users to invite your bot, you just need to share them this link!

Make it so that a someone cannot react to a discord message until a channel has been deleted

So basically I have a support bot that creates a channel when someone reacts that only staff have access to. In order to prevent abuse I want to make it so that a new channel channel cannot be created by the same person unless the a previously open channel is deleted.
Give your bot access to the AuditLogs will allow you to see who is creating the channels but I suspect that's not gonna help because the bot will be the one creating and deleting the channels, for the discord server he is the owner of the action.
Maybe the only way is to store in the bot code a map of the channel id and his owner (user that typed the command). With this every time a user try to create a new channel you can check on your map if there is any channel active for that user and if there is show some kind of error message.

How to transfer a discord server ownership with a bot

There is any way of transfering a discord server ownership with a bot?
I have beed told that there is a way to do this with a python bot but I didn't figure out how.
It seems that a method exists on the discord.js wrapper. .setOwner()
I couldn't find a way to see if it really works. ^^
// Edit the guild owner
guild.setOwner(guild.members.cache.first())
.then(updated => console.log(`Updated the guild owner to ${updated.owner.displayName}`))
.catch(console.error);
you can actually change server ownership with a bot. but the bot must be the owner of the server before hand.
for a bot to create a guild it must use POST /guilds
to change owners you must use PATCH /guilds/{guild.id} and send over the json parameter owner_id with the id you want to transfer ownership too.
Offical Discord Documentation Links:
https://discordapp.com/developers/docs/resources/guild#create-guild
https://discordapp.com/developers/docs/resources/guild#modify-guild

How to add or remove users from a Discord server via the API

I am selling a SaaS product that comes with a Discord server for users. This is a renewal product, so if the user's license expires then I would like to remove them from the server.
How can I achieve this? What input will they need to give me? Is it best to have a login with discord button on my website or should I just have them give me their username then I can send them an invite link when they register, and remove them if their license expires using the API. What if they change their username?
I have done my best to figure out how to achieve both of these approaches by reading https://discordapp.com/developers/docs/intro, but I feel their documentation is seriously lacking and it is difficult to find what I need.
EDIT: It would also be useful to be able to generate one time only invite links. Once the user clicks the link, their discord user ID is sent to me so I can add it into the database. Then, say every day, I scan the database for expired users and if that user has expired then I invoke kick https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.kick. Is this possible?
you get their discord id as soon as they join the discord server by using
client.on('guildmemberadd', (member) {
console.log(member.id)
{```
from there you can hook in your database and simply create a entry containing their
member.id member.username and whatever else you require by a join date Date.now()

How to get list of all the servers to which discord owner is connected

Is there any API to get list of all the servers to which the discord owner(user) is connected.
I want to write a bot to manage all the servers connected to discord owner's account.
As Jeremy mentioned you can use  https://discordapp.com/developers/docs/resources/user#get-current-user-guilds if logged in as the user you're trying to get guilds of. A total list of Guilds isn't possible to get for other users though, you'll only get mutual/shared guilds displayed for others.

Resources