-
-
Save fazt/e17ea3fde6988f7215301b888ccaaf5c to your computer and use it in GitHub Desktop.
import discord | |
from discord.ext import commands | |
import datetime | |
from urllib import parse, request | |
import re | |
bot = commands.Bot(command_prefix='>', description="This is a Helper Bot") | |
@bot.command() | |
async def ping(ctx): | |
await ctx.send('pong') | |
@bot.command() | |
async def sum(ctx, numOne: int, numTwo: int): | |
await ctx.send(numOne + numTwo) | |
@bot.command() | |
async def info(ctx): | |
embed = discord.Embed(title=f"{ctx.guild.name}", description="Lorem Ipsum asdasd", timestamp=datetime.datetime.utcnow(), color=discord.Color.blue()) | |
embed.add_field(name="Server created at", value=f"{ctx.guild.created_at}") | |
embed.add_field(name="Server Owner", value=f"{ctx.guild.owner}") | |
embed.add_field(name="Server Region", value=f"{ctx.guild.region}") | |
embed.add_field(name="Server ID", value=f"{ctx.guild.id}") | |
# embed.set_thumbnail(url=f"{ctx.guild.icon}") | |
embed.set_thumbnail(url="https://pluralsight.imgix.net/paths/python-7be70baaac.png") | |
await ctx.send(embed=embed) | |
@bot.command() | |
async def youtube(ctx, *, search): | |
query_string = parse.urlencode({'search_query': search}) | |
html_content = request.urlopen('http://www.youtube.com/results?' + query_string) | |
# print(html_content.read().decode()) | |
search_results = re.findall('href=\"\\/watch\\?v=(.{11})', html_content.read().decode()) | |
print(search_results) | |
# I will put just the first result, you can loop the response to show more results | |
await ctx.send('https://www.youtube.com/watch?v=' + search_results[0]) | |
# Events | |
@bot.event | |
async def on_ready(): | |
await bot.change_presence(activity=discord.Streaming(name="Tutorials", url="http://www.twitch.tv/accountname")) | |
print('My Ready is Body') | |
@bot.listen() | |
async def on_message(message): | |
if "tutorial" in message.content.lower(): | |
# in this case don't respond with the word "Tutorial" or you will call the on_message event recursively | |
await message.channel.send('This is that you want http://youtube.com/fazttech') | |
await bot.process_commands(message) | |
bot.run('token') |
how do u make the status playing or listening to helping server
bot.change_presence(activity=discord.Streaming(name='.help')
bot.change_presence(activity=discord.Game(name='.help')
how do i change the ".help" command text, because i cant find it in the code.
how do i change the ".help" command text, because i cant find it in the code.
Yeah, and I was trying to make ".help" commands list embed but I can't find any code in the script.
existe un pequeño problema al buscar el video lo solucione reemplazando la expresión regular
search_results = re.findall( r"watch\?v=(\S{11})", html_content.read().decode())
Gracias
How to read an embed message , let say a bot is sending embed messages daily twice to me 1 is for success and 1 is for failure .
So i want my bot to read those messages and ping me only when Successful word is present in the embed message.
I can read normal message but embed is a pain if you can help please thanks
existe un pequeño problema al buscar el video lo solucione reemplazando la expresión regular
search_results = re.findall( r"watch\?v=(\S{11})", html_content.read().decode())
existe un pequeño problema al buscar el video lo solucione reemplazando la expresión regular
search_results = re.findall( r"watch\?v=(\S{11})", html_content.read().decode())
Muchísimas gracias por tu aporte!!! Súper valioso, no sabía como hacer que funcione las búsquedas.
how do u make the status playing or listening to helping server
bot.change_presence(activity=discord.Streaming(name='.help')
bot.change_presence(activity=discord.Game(name='.help')
where do I need to put this?
Te está diciendo que el array search_results[0] está vacío. Eso pasa porque ahí un problema en la forma en que busca los vídeos. Más arriba está la solución. Si debuggeas el array ese vas a ver qué está vacio
I have a problem with the YouTube part
.
search_results = re.findall( r"watch?v=(\S{11})", html_content.read().decode()) esa es la solución, NO ES MIA. MAS ARRIBA ESTA EL AUTOR
import aiohttp
@bot.command(name="quote", help="get amazing random quote")
async def getRandomQuote(ctx):
""" Get amazing random quote """
randomQuoteURL = 'https://zenquotes.io/api/random'
async with ctx.typing():
async with aiohttp.ClientSession() as session:
async with session.get(randomQuoteURL) as response:
if response.status == 200:
result = await response.json()
randomQuote = f'{result[0]["q"]} -**{result[0]["a"]}**'
await ctx.send(randomQuote)
else:
await ctx.send(f"API is not available, Status Code {response.status}")
Do embed.set_thumbnail(url=f"{ctx.guild.icon_url}")
instead of embed.set_thumbnail(url=f"{ctx.guild.icon}")
in order to get the guild icon ref: line 25
how can I add random gifs? Everyone knows these annoying bots with like !hug !kill etc.
how can I add random gifs? Everyone knows these annoying bots with like !hug !kill etc.
you can use APIs to get random gif.
how do u make the status playing or listening to helping server
bot.change_presence(activity=discord.Streaming(name='.help')
bot.change_presence(activity=discord.Game(name='.help')
where do I need to put this?
in @bot.event line
@devjaime muchas gracias por tu aporte. Ha sido de gran ayuda!
what command do you need to enter to use the embed?
this bot wont work without token, please send your token.
this bot wont work without token, please send your token.
What?? Are you idiot?
this bot wont work without token, please send your token.
What?? Are you idiot?
bro why are you mean, the bot wont work without token, please give the token so i can run the bot.
this bot wont work without token, please send your token.
What?? Are you idiot?
bro why are you mean, the bot wont work without token, please give the token so i can run the bot.
U r really an idiot why would anyone share the token
this bot wont work without token, please send your token.
What?? Are you idiot?
bro why are you mean, the bot wont work without token, please give the token so i can run the bot.
U r really an idiot why would anyone share the token
Duh, the bot wouldn't work without the token, that's why.
this bot wont work without token, please send your token.
What?? Are you idiot?
bro why are you mean, the bot wont work without token, please give the token so i can run the bot.
U r really an idiot why would anyone share the token
Duh, the bot wouldn't work without the token, that's why.
Create a bot then use your own token.
this bot wont work without token, please send your token.
What?? Are you idiot?
bro why are you mean, the bot wont work without token, please give the token so i can run the bot.
U r really an idiot why would anyone share the token
Duh, the bot wouldn't work without the token, that's why.
Create a bot then use your own token.
Pretty sure that's a ploy to get me to use your token logger 😐
this bot wont work without token, please send your token.
What?? Are you idiot?
bro why are you mean, the bot wont work without token, please give the token so i can run the bot.
U r really an idiot why would anyone share the token
Duh, the bot wouldn't work without the token, that's why.
Bro are you joking why will someone share their token go get your own token from https://discord.com/developers/applications
How do you add a command?
wich discord.py version i just had for that
this bot wont work without token, please send your token.
What?? Are you idiot?
bro why are you mean, the bot wont work without token, please give the token so i can run the bot.
U r really an idiot why would anyone share the token
Duh, the bot wouldn't work without the token, that's why.
bruh no one just make tyour own token DUHHHHHHHHH DUMMY
How do you add a command?
For every command use this:
async def ping(message):
print("Recieved ping from {0.author}".format(message))
await message.channel.send('pong')
Thx