So I saw this fields columns in some embed and I realized that my embeds are boring. My question is - how this columns are made? is it an image or something? how can I add these columns to my embeds? Are these emojis? if so where can I get them? I know I ask too many questions but I am just curious. Thanks
You can use the > symbol to make those columns.
I've remade the embed shown in the picture:
import discord, datetime
from discord.ext import commands
client = discord.ext.commands.Bot(command_prefix = "!");
#client.command()
async def embed(ctx):
embed = discord.Embed(
title = "Deep Stone Crypt Void Run",
description = "All void subclass run of Deep Stone Crypt for the triumph.\nExperience optional.",
colour = discord.Colour.from_rgb(241,196,15)
)
embed.add_field(name="Time", value="Mon Dec 7th, 2020 • 6pm - 9pm PST (UTC-8)", inline=False)
embed.add_field(name="Links", value="[Add to calender](https://discordapp.com)\n[Convert time zone](https://discordapp.com)", inline=False)
embed.add_field(name="\✅ Accepted (4/6)", value="> TMC\n> ArcaneVoid\n> LilRemsy\n> Asal", inline=True)
embed.add_field(name="\❌ Declined (2)", value="> Joe_Hammersmash\n> Jeiyiu", inline=True)
embed.add_field(name="\❔ Tentative (2)", value="> Awoken Phoenix\n> datigren186", inline=True)
embed.set_footer(text="Created by TMC\nLocal time")
embed.timestamp = datetime.datetime.now()
await ctx.send(embed=embed)
client.run("token_here")
Output:
Check out this article to learn more about Discord markdown.
Related
Hello I recently made a help command using discord_components buttons (I know they arent fully supported by Discord.py) but I still went ahead. The problem is that whenever I run the command and receive the Buttons to click on, they alway say "This Interaction Failed". I can't seem to find what's wrong. Please help.
Thanking You,
NightMX.
import discord
from discord.ext import commands
from discord_components.component import ButtonStyle
from discord_components import DiscordComponents, Button, Select, SelectOption
from discord_components.interaction import InteractionType
class BotCommands(commands.Cog):
def __init__(self, client):
self.client = client
#commands.command()
async def helpv2(self, ctx):
funbutton = Button(style=ButtonStyle.grey, label="Fun Commands", id="funcmds")
monkedevbutton = Button(style=ButtonStyle.grey, label="Attachment Commands", id="monkecmds")
# utilitybutton = Button(style = ButtonStyle.grey, label = "3", id = "embed3")
funembed = discord.Embed(title="Fun Commands", colour=discord.Colour.orange())
funembed.add_field(name="k.joke", value="Sends a Random joke from PyJokes")
monkedevembed = discord.Embed(title="Fun Commands", colour=discord.Colour.blurple())
monkedevembed.add_field(name="k.dog", value="Sends a Random Dog Fact")
monkedevembed.add_field(name="k.monkey", value="Sends a Monkey's Picture")
monkedevembed.add_field(name="k.bird", value="Sends a Bird's Picture")
await ctx.send(
"Kola's Beta Help Command!",
components=[[funbutton, monkedevbutton]]
)
buttons = {
"funcmds": funembed,
"monkedcmds": monkedevembed
}
while True:
event = await self.bot.wait_for('button_click')
if event.channel is not ctx.channel:
return
if event.channel == ctx.channel:
response = buttons.get(event.component.id)
if response is None:
await event.channel.send(
"Something went Wrong"
)
if event.channel == ctx.channel:
await event.respond(
type=InteractionType.ChannelMessageWithSource, embed=response
)
def setup(client):
client.add_cog(BotCommands(client))
should be content="something" instead of embed = response
if I input !3people Job Offer I got this image's error. Please resolve my error.
My OS is windows 10 home and discord.py version is 1.0.1
Thank you.
if m.content.startswith('!') and 'Job Offer' in m.content:
if m.content\[1\].isdigit()!=True or int(m.content\[1\]) > 3 or int(m.content\[1\]) <= 0:
embed = discord.Embed(color=0x06afff)
embed = discord.Embed(title="Squad", color=0x06afff)
embed.add_field(name="warning", value="Please input correct value.", inline=False)
await m.channel.send(embed=embed)
else:
comment = ''
for i in m.guild.voice_channels:
if m.author in i.members:
embed = discord.Embed(title="Squad", color=0x06afff)
print(i.create_invite())
embed.add_field(name="Squad", value=(await i.create_invite()), inline=False)
print(i)
embed.add_field(name="Title", value=i, inline=False)
cnt=4-int(m.content\[1\])
embed.add_field(name="user count", value='%d /4'%(cnt), inline=False)
if 'Job Offer' in m.content:
comment = m.content.split('Job Offer')\[1\]
if len(comment) == 0:
comment = 'Today's finish is chicken'
embed.add_field(name="Comment", value=comment, inline=False)
await m.channel.send(embed=embed)
await m.channel.send('#here')
Error Image
create_invite is a coroutine so it needs to be awaited.
The simple fix is to edit line 12:
print(await i.create_invite())
Adding the await before i.create_invite() should solve the issue.
So, I'am building a discord bot for my private server with python. I want it to reply to a message when a specific message is written for example a person would write "Hi!" and the bot would respond "Hi!". I tried the code #bot.event async def on_message(Hi!): await message.send("Hello!") but it doesn't work. The error is "name 'bot' is not defined". Can any of you help? Here is my whole code NOTE: IT'S IN LITHUANIAN LANGUAGE AND IT'S AMONG US THEMED
```import discord
import random
from discord.ext import commands
from random import choice
client = commands.Bot(command_prefix = '/', help_command=None)
status = ['Žudau crewmates', 'Apsimetinėju :eyes:', 'Prižiūriu https://discord.gg/FNsBtsA']
#client.event
async def on_ready():
print('Imposteris pasiruošęs.')
#client.command()
async def komandos(ctx):
await ctx.send(f'/ping - parodo jūsų interneto greitį, /patarimas - botas duoda patarimą Among Us žaidimui, /meme - Duoda kokį nors among us meme.')
#client.command()
async def ping(ctx):
await ctx.send(f'Pong! {round(client.latency * 1000)}ms')
#client.command()
async def patarimas(ctx):
choices = ["Jei nori būti imposter, pasirink orandžinę spalvą. Ši spalva turi netgi 15.48% tapti imposter. Mažiausiai šansų turintis tėra violetinis. Jis turi tik 3.8%, kad tapti imposter.", "Jei nori kažką nužudyti nueik į admin, susirask tolimiausia nuo electrical, uždaryk savo auką su durimis, išjunk šviesas. Taip gausi kill'ą.", "Jei esi crewmate, niekuo nepasitikėk nebengi žmogus padarė visual task'ą (nesvarbu ar bar pakilo ar ne). Jei esi sus, sakyk, kad turi visual task'ą (jeigu aišku tokį turi).", "Jeigu matai žmogų kuris daro cardswipe, o tu jo neturi, jis bus imposteris. Tai common task'as, jį gali turėti visi arba niekas.", "Pati saugiausia vieta The Skeld žemelapyje yra communications. Ten retai kas užeina. O Polus saugiausia vieta pats startas. Mira HQ saugiausia vieta yra communications "]
ranpatarimas = random.choice(choices)
await ctx.send(ranpatarimas)
#client.command()
async def meme(ctx):
choices = ["https://imgur.com/a/MvYabuk", "https://imgur.com/a/cKEp545", "https://imgur.com/a/5D4XVLl", "https://imgur.com/a/6IioFXt", "https://imgur.com/a/KdVz4WE", "https://imgur.com/a/BlLPvvc", "https://imgur.com/a/aKEMcfO", "https://imgur.com/a/e7Mnu9t", "https://imgur.com/a/sVfVodl", "https://imgur.com/a/F9Zz4A0", "https://imgur.com/a/vbCDxww", "https://imgur.com/a/3K0AHR3"]
ranmeme = random.choice(choices)
await ctx.send(ranmeme)
#bot.event
async def on_message(mirk):
await message.send("NE! Mano mačas dar nesibaigė, o impostorium aš vis dar esu. Palauk prašau kol visus išžudysiu arba bent jau kai būsiu išvoteintas :slight_frown:)")
client.run(<TOKEN>)```
This is a simple code just to get the idea.
#bot.event
async def on_message(message):
if message.author == bot.user: # skip bot messages
return
# write all possible words in lower case.
if message.content.lower() in ['hey', 'hi', 'hello']:
await message.channel.send('Hello!')
await bot.process_commands(message) # to allow other commands
Refrance but not for a bot instead a client it is the same.
Your current solution will respond to every message sent to your server or to your bot dm's, no matter what's the content of it. You can simply check for it.
#client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.lower() == 'hi!':
await message.channel.send('Hi there')
await client.process_commands(message)
And change your token, now
Reference:
message
EDIT:
Answering your comment, here's how to check if any word is in the message content
if any(word in message.content.lower() for word in ['hi', 'hello!']):
await message.channel.send('Hi there')
# or
if message.content.lower().startswith(['hi', 'hello!']):
await message.channel.send('Hi there')
I am making a bot that has an announcement at a different time on each weekday. I want to go about the process of making this by having 5 discord task loops that send the announcement on their respective days. They will activate on their respective Unix timestamps and then will reactivate on the the timestamp is refreshed for the next week.
How do I make a an #client.event that activates on a Unix timestamp?
import discord
from discord.ext import commands, tasks
import random
import datetime
client = commands.Bot(command_prefix='.')
orig = datetime.datetime.fromtimestamp(1425917335)
new = orig + datetime.timedelta(days=90)
target_channel_id = 123456789
list_warning = ["T minus... 5 minutes... until detonation.", "Teacher is waiting. Get your ass back in 5 minutes.", "300 seconds unt-, 299 seconds unt-, 298 seconds unt-...",
"Chow down boys, lunch ends in 5 minutes.", "Looks like you've got some schoolin' to do."]
list_time = [1, 10]
#loops the 5 minute warning for lunch to end
#tasks.loop(seconds=)
async def called_once_a_day():
message_channel = client.get_channel(target_channel_id)
print(f"Got channel {message_channel}")
await message_channel.send(random.choice(list_warning))
org = orig + datetime.timedelta(days=7)
#called_once_a_day.before_loop
async def before():
await client.wait_until_ready()
print("Finished waiting")
called_once_a_day.start()
client.run("")
I would consider a more naive solution. Simply loop frequently and check if you at lunch time, if so send the lunch message. I tend to use arrow because I find it easy to use... you could implement with other libraries
tuesday_lunch_time = arrow.get("1230","HHmm")
#loop every minute so we are within a minute of lunch time.. you could change this to loop more often
#tasks.loop(minutes=1)
async def called_once_a_day():
now = arrow.now()
if now.weekday()== 1: #is today tuesday, don't ask me why tuesday is 1
if tuesday_lunch_time.shift(minutes=2).time() > now.time > tuesday_lunch_time.time(): ###this checks if you are within two minutes after lunch time, you could change this if you want to say have it be early, because of our loop it should be within a minute but I picked two minutes to be safe
message_channel = client.get_channel(target_channel_id)
print(f"Got channel {message_channel}")
await message_channel.send(random.choice(list_warning))
#to get out of the conditional above, so you don't send multiple times
await asyncio.sleep(720)
Not sure if its the lack of coffee, but I'm having a slight issue with uploading random images.
#client.command(aliases=['cuddle'])
async def _cuddle(ctx, *, user):
image= [
'file_1.gif',
'file_2.gif',
'file_3.gif',
'file_4.gif',
'file_5.gif',
'file_6.gif',
'file_7.gif']
await ctx.send(f'You got a Cuddle from{ctx.message.author.mention}, {user}!\n {random.choice(file =discord.file(image))}')
its mostly the
{random.choice(file =discord.file(image))}
ive tryed
discord.file'file_1.gif', method but with no prevail.
I've solved it for anyone who wants to know
import os
#commands.command(aliases=['image'])
async def images(self, ctx):
image = os.listdir('./cogs/image/')
imgString = random.choice(image) # Selects a random element from the list
path = "./cogs/image/" + imgString
await ctx.send(file=discord.File(path))