Using Discord Bot To Display Youtube Video - discord

I want my discord bot to send basic youtube embeds that appear automatically when a link from youtube is pasted on discord by a user.
I do know i need to install and use pytube for this.
Just need some direction on how to connect my bot to youtube.
(I'm new to discord.py)
For example i do !yt mango and the bot sends the top 3 results that come when searched for mango on youtube.
Please help me out

I want my discord bot to send basic youtube embeds that appear automatically when a link from youtube is pasted on discord by a user.
auto-embeds is a default functionality of Discord. When someone posts a link and you have auto-embeds enabled for the server you will be able to watch the YouTube video from the Discord client.
I do know i need to install and use pytube for this.
pytube is for downloading YouTube videos. You don't need to download the video. Thus pytube is not needed.
Just need some direction on how to connect my bot to youtube.
(I'm new to discord.py)
Familiarize yourself with discord.py first. Here is the manual:
https://discordpy.readthedocs.io/en/stable/api.html
Get a basic discord bot running before attempting anything more advanced.
For example i do !yt mango and the bot sends the top 3 results that come when searched for mango on youtube.
To be able to search on YouTube you need Google API. Refer to: https://developers.google.com/youtube/v3/quickstart/python
Here is a possible library you could use: https://pypi.org/project/python-youtube/
On StackOverflow we don't write code for you. We can only guide you in the direction but you have to write the actual code yourself or be more specific with your problem. Break your big problem into smaller tasks and solve those.
StackOverflow is more for debugging faulty code.

Related

How do I create a stickied message in Discord.js

I've looked all over and I can't find a solution.
I'm using discord js using non-slash commands.
How could I make it so you have a message from the bot and if someone types in the channel the bot's message will get deleted and resent
I want to do this in a sense of a server request channel so you need to add the channel you want the command to run and what you want it to say:
e.g:
Stickied Message
Name:
Request Needed:
Approved By:
how could I program that? Thanks :) <3
I ahve googled online and can't see anything relating to this topic - maybe I'm not searching the right things?
Tried Discord.js V13 | Sticky Message but did not work

Not managing to transfer my code onto a different bot

So I have my bot which I now transferred onto a Heroku server, with this I made a new bot which I named ex Test Bot, but for some reason when I went into my config.json with the code
{
"token": "DISCORD BOT ID THING"
}
Now when I change the following to my test bots ID which I will run from my PC, it gives me this wierd error
I really have no clue searched online couldnt fined anthing, I hope one of you guys could help. Thanks!
You're probably using an intent that you don't have permission to use or isn't enabled.
You'll have to go to Discord Developer Portal, choose your application, go to the Bot section, and enable all the intents. (Or the ones you are using.)
Note that once your bot reaches 100 or more servers, this will require verification and whitelisting.
Bot Verification and Data Whitelisting

Discord bot to check if a minecraft server is online

I was wondering if anyone knew of a discord bot that will send a message in a discord sever when a minecraft server is online and send a message when it goes back offline
I've done some googling and can't seem to find one that does what I want there are a couple that u have to manually type commands for and others that appear in the sidebar of discord I simply want one that will do it automatically is there one that exists like this already?
I didn't found any not that already did this, but you can do this pretty easily with the Discord API.
Here is a a script I found that send a message to the server : https://gist.github.com/ianklatzco/769d9e3a991dc2f443a2e105b0157117
You can adapt it to ping the server in a if statement to send if it is online or not
(This script is in python but the Discord api works in more languages)

Discord Bot [Help Needed] [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I need help with a discord bot and coding I never actually coded a discord bot so this is what I need help with. So I need help with making a discord bot chat like if I was to make rules it could make the rules chat pop up like
[USERNAME]
;Rules
Delete The Message I Said
[BOT]
Rules Here
Like this image
This is quite the lengthy response, but I recommend reading the entire thing.
StackExchange is a community where people post and discuss code. With all do respect, I can guarantee you that nobody here, including me, is going to write you code if we cannot see what you have tried or any existing code.
You will definitely have better luck on this site if you have a relevant product that people can look at to find errors and/or help you build upon it.
In the meantime, check out the Unofficial User Discord API Server here: https://discordapp.com/invite/discord-API
When I was in your shoes, this discord server was extremely helpful with answering any questions about the Discord API as 99.9% of the people there know exactly what your issue is and how to solve it. People are always online to take your questions as you build your code.
If you need help with starting your code, the basic steps go as follows:
Pip install the discord API
Create a bot user on https://discordapp.com/developers/docs/intro
Use the bot token to write your code
Because I don't know exactly what progress you have made on your bot thus far, I just strung together some wireframe code in python to get started.
import discord
import asyncio
from discord.ext import commands
description = "desc"
bot = commands.Bot(command_prefix='?', description=description)
#startup command
#bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
#category of main commands
class Main_Commands():
def __init__(self, bot):
self.bot = bot
#ping command test
#bot.command(pass_context=True)
async def ping(ctx):
await bot.say("pong")
#when the user types in ?ping, the bot will return "pong"
#This is an example of a simple command in this language
#RunBot
bot.run("TOKEN GOES HERE")
# (C) 2017
# All rights reserved
# Any part of this program may be used and/or modified at the users discretion
Anyways, I hope this response helped you.
Happy Coding!!
P.S. check out the API Reference http://discordpy.readthedocs.io/en/latest/index.html
What is in that image is an embed. Im my opinion, Discord.js is a very user friendly Discord API. You can find the docs here.
Rich embeds come with the Discord API, and they are really easy to use. Here is an example.
const embed = new Discord.RichEmbed()
message.channel.send({embed});
To actually put something in the message of your embed, you want to add attributes to the embed. They are as follows:
Attributes:
.title("title name")
.setAuthor("Author Name", "URL to picture you want to the left of name, optional")
.setColor(hex color code)
.setDescription("text")
.setFooter("text", "URL to image")
.setImage("URL to image")
.setThumbnail("URL in top right of embed")
.setTimestamp()
timestamp is at the at the bottom, nothing goes in the function
Attributes, continued:
.setURL("URL to make title clickable")
.addField("bold text",
"text")
this is what was used in the image you linked, there can be more than one field.
One more attribute:
.addBlankField(true)
To send the embed, in discord.js, simply do
message.channel.send({embed});
you defined embed earlier

Show Discord bot as online

I'm working on a custom Discord bot using their api. Sending HTTP requests work but the bot doesn't actually show itself as online.
Other bots such as Dynobot are able to show themselves as online, am I missing something or is it just a case of how many requests are sent?
Wait, are you working directly with the API, as in sending HTTP requests?
If so...there really is no need to do this. Instead, use a library to code your Discord bot. Here is a list of official libraries for the Discord API. Personally I recommend Discord.js, although I have heard that Discord.py and Discord.NET are also good.
If you want to keep using the API directly, which I do not recommend at all, I believe you can call /api/login. Have you tried that yet?
I hope this helped! :)

Resources