#discord-bots
1 messages ยท Page 495 of 1
role.members.__len__()
Imagine pinging individuals instead of the role 
Eh, I also pinged mods in #bot-commands haha
o.o
I'd recommend pinging mod role eitherway, it ensures that some active mod sees it, since online status doesn't really tell if the mod can take an action or not at the moment
okay sorry
No need to be sorry, just a headsup, we won't punish people for pinging mods unless they do it for trolling sake or something along those lines
@boreal ravine you're working with buttons right?
not atm
You wanna give me a quick crash course on how to use them? ๐
Just trying to get a basic button xD
hm well I use py-cord lel
oh
Painful
Hey @drifting arrow, I can help you with buttons! (I have made a paginator myself with those in like 50 lines or something)
I know it can be a pain in the start, but they are F. U. N.
Brilliant. Alright. what imports do I need and how to I create a basic button?
Once I get the basics down I can go back to relying on the documentation lol
flex

@commands.command(name="setstatus")
async def setstatus(self, ctx: commands.Context, *, text:str):
await self.bot.change_presence(activity=discord.Game(name=text))``` gives me the error command not found
Waiting for him to press enter ๐ฎ
have you load the cog?
idk what name does, but remove it
def setup(bot: commands.Bot):
bot.add_cog(SomeCommands(bot))```
@commands.command(name="setstatus") should just be @commands.command()
should just be the same
no its like a command
to change the status of a bot
have you load the extension?
uhh what extension?
!d discord.ext.commands.Bot.load_extension
load_extension(name, *, package=None)```
Loads an extension.
An extension is a python module that contains commands, cogs, or listeners.
An extension must have a global function, `setup` defined as the entry point on what to do when the extension is loaded. This entry point must have a single argument, the `bot`.
A basic example on how to use buttons in discord.py
from discord.ui import Button
from discord.ui import View
class MyButton(Button):
def __init__(self):
super().__init__(kwargs-here)
async def callback(self, inter):
# logic here when the button is clicked
@bot.command()
async def button(ctx):
view = View()
view.add_item(Button())
await ctx.send("Button Incoming!!!", view=view)
ctx: commands.Context what's this doing? i dont understand
bot.load_extension("filename")
I did all this on a mobile, so don't blame me if any syntax error please
A Context object is always the first parameter passed to a comman
its the command name like
@client.command(name="uwu") # name as in command name
async def owo(ctx, **args): # cant use !owo u can only do !uwu now
The name of the command.
ohh wait
(:
i need to load extension lol
type wot
yeah
lel
im so dumb
this 
sad
I am first (:
im on mobile with trash auto correct and auto space after dot

I am also on mobile (:
gae
Who says
you never typed anything incorrect
It's just used to me typing the discord.ext.commands
actually yeah me too
@maiden fable Can I put buttons inside of an embed? or is it always at the end?
Always at the end
And u need either an embed or a content, u can't send only Buttons/Dropdown
๐ฆ error
from discord import MessageInteraction
How do I add the voice support version of discord.py into my requirements.txt? can I just do discord.py[voice]==some.version.here?
What's the error?
cannot import name 'MessageInteraction' from 'discord'
Remove that then
pip install discord.py[voice]
that ought work, i think
it needs to be in this format
await ctx.send("Button Incoming!!!", view=type("MyButton", (Button,), {"__init__": lambda self: super().__init__(kwargs-here), "callback": lambda self, inter: ...})
``` *to be cool
Ah sure then
alright i'll try that out
Ok, thanks for ducking with my mind (:
its cool isnt it?
"cool"
@maiden fable is it possible to add text between each button? or define how many is on each line?
say I want <button> Click that. <button> Or this one.
Nope
They are always at the last
Can I atleast define how many is displayed in a row? ;-;
@visual island doesnt work
I'd much like that to be in lots of 3 not 5 xD
commands.command(name="setstatus")
async def setstatus(self, ctx: commands.Context, *, text:str):
await self.bot.change_presence(activity=discord.Game(name=Text))```
Sure
How?
can someone help my setstatus comand is not working
@commands.command(name="setstatus")
async def setstatus(self, ctx: commands.Context, *, text: str):
await self.bot.change_presence(activity=discord.Game(name=text))```
How would I check if a button has been pressed?
The callback method is executed when it's pressed
Wym "not working"
guys when i make an 8 ball it only shows the first word of the question
Question By T I m N o O n e T๐
=>is
Answer By Peachy Bot :
=> I Guess No .
Still cant figure this shit out ;-;
Doesn't help that everything on the internet is either outdated or just not caught up
Can I see your code
@commands.command()
async def theboard(self, ctx):
myboard = {'7': 'Empty' , '8': 'Empty' , '9': 'Empty' ,
'4': 'Empty' , '5': 'Empty' , '6': 'Empty' ,
'1': 'Empty' , '2': 'Empty' , '3': 'Empty' }
view = View()
view.add_item(Button(label= myboard['7'], custom_id=7,row=1))
view.add_item(Button(label= myboard['8'], custom_id=8,row=1))
view.add_item(Button(label= myboard['9'], custom_id=9,row=1))
view.add_item(Button(label= myboard['4'], custom_id=4,row=2))
view.add_item(Button(label= myboard['5'], custom_id=5,row=2))
view.add_item(Button(label= myboard['6'], custom_id=6,row=2))
view.add_item(Button(label= myboard['1'], custom_id=1,row=3))
view.add_item(Button(label= myboard['2'], custom_id=2,row=3))
view.add_item(Button(label= myboard['3'], custom_id=3,row=3))
await ctx.send("Your board", view=view)
#print(Button.callback)
def check(m):
return ctx.author.id == 197979859773947906
button_callback = Button.callback
interaction = await self.client.wait_for(button_callback)
await ctx.send(f"you clicked button {interaction.component.custom_id}")
await interaction.respond(content=f"you clicked button {interaction.component.custom_id}")
can i see how you loaded it?
can anyone help me
Send code
Nonono it's wrong
Ofc it's wrong. coz it's not working xD
U set the callback by subclassing Button
Or I have another idea
class MyView(View):
@button(kwargs)
async def button_1_click(self, inter):
# what will happen if this button is clicked
Then you can make your game
That's how I made my paginator
async def Pball(ctx , question):
username = str(ctx.author).split('#')[0]
user_message = str(ctx.message.content)
channel = str(ctx.channel)
eightball = ['Yes','No','Probably','Of Course','Of Course No','From my point of view , yes','100% No','I Donnow','Ask Me Later','Im Busy , Sorry ','Im sure yes','I Guess No']
embedVar = discord.Embed(title=f"โฆPeachy Botโฆ\n Question By {username} ",color=0x00ff00)
embedVar.add_field(name=f"Question By {username}", value=(f'=>{question}'),inline=False)
embedVar.add_field(name="Answer By Peachy Bot :", value=(f'=> {random.choice(eightball)} .'),inline=False)
await ctx.send(embed=embedVar)
return ```
should it be @button or @Button? ๐ค coz i got an error with a lowercase B
you need to do async def Pball(ctx, *, question):
from discord.ui import button
!d discord.ui.button
discord.ui.button(*, label=None, custom_id=None, disabled=False, style=<ButtonStyle.secondary: 2>, emoji=None, row=None)```
A decorator that attaches a button to a component.
The function being decorated should have three parameters, `self` representing the [`discord.ui.View`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.View "discord.ui.View"), the [`discord.ui.Button`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Button "discord.ui.Button") being pressed and the [`discord.Interaction`](https://discordpy.readthedocs.io/en/master/api.html#discord.Interaction "discord.Interaction") you receive.
Note
Buttons with a URL cannot be created with this function. Consider creating a [`Button`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Button "discord.ui.Button") manually instead. This is because buttons with a URL do not have a callback associated with them since Discord does not do any processing with it.
There
@maiden fable Sorry for ping, do you know how to seperate MemberNotFound/RoleNotFound from BadArgument since the NotFound's are inherited from BadArgument?
Like make an error handler for MemberNotFound that doesn't raise BadArgument
If MemberNotFound is a subclass of BadArgument, it's not possible
Well, I don't think there's any way
But you can check the type of the error
Was gonna say that
if type(error) == commands.MemberNotFound :
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
if isinstance(error, commands.CommandOnCooldown):
rounded = round(error.retry_after)
embed=discord.Embed(description=f"{self.bot.cross_emote} {ctx.author.name}, this command is on cooldown. Please try again in {rounded} seconds", color=discord.Color.red())
msg = await ctx.send(embed=embed, delete_after=4)
elif isinstance(error, commands.MemberNotFound):
await ctx.send(embed=discord.Embed(description=f"{self.bot.cross_emote} I could not find that member", color=discord.Color.red()))
elif isinstance(error, commands.MemberNotFound):
await ctx.send(embed=discord.Embed(description=f"{self.bot.cross_emote} I could not find that role", color=discord.Color.red()))
this is what i have
This will check for first MemberNotFound, then BadArgument
yeah, did that to solve it.
anyway, thanks though
Why two memer not found
Isn't it better to check the type of the error then error is SomeError?
Or is there no difference?
Oops it is should be RoleNotFound
Same thing?
I think
I was told that to solve i need OOP specificially child and parent inheritance
but have no idea lol
Was just logic
I am on mobile
Ah ok lol
i need help
With?
how i can get all votes of bot in discord.py?
can someone help me create an array of discord.SelectOptions since it gives me ```py
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Object of type SelectOption is not JSON serializable
lib?
does discord.HTTPException hapeen a lot? Or is it just when a command fails
This error occurs when the bot does not have access or the bot cannot find the channel or message it says
how to remove cogs properly
@commands.guild_only()
# Command cannot be used in private messages.
@commands.is_owner()
# Command can only be used by the bot owner.
@commands.is_nsfw()
# Command can only be used in NSFW channels
@commands.has_role("name")
# Check if member has a role with the name "name"
@commands.bot_has_role(11132312313213)
# As above, but for the bot itself. (name can be replaced with id)
@commands.has_any_role(["role1","foo",11132312313213])
# Check if user has any of the roles with the names "role1", "foo", or the role with id 11132312313213
@commands.bot_has_any_role(*roles)
# As above, but for the bot itself
@commands.has_permissions([ban_members=True, kick_members=True])
# Check if user has all of the passed permissions
# e.g. this command will require both kick and ban permissions
@commands.bot_has_permissions(**perms)
# As above, but for the bot itself.
@commands.has_guild_permissions(**perms)
@commands.bot_has_guild_permissions(**perms)
# As for the two above, but for guild permissions rather than channel permissions.
@commands.check(myfunction)
# Check against your own function that returns those able to use your command
@commands.check_any(*myfunctions)
# Command will be ran if the conditions of any of your own check functions are met
from discord.ext.commands.cooldowns import BucketType
# BucketType can be BucketType.default, member, user, guild, role, or channel
@commands.cooldown(rate,per,BucketType)
# Limit how often a command can be used, (num per, seconds, BucketType)
@commands.max_concurrency(number, per=BucketType.default, *, wait=False)
# Limit how many instances of the command can be running at the same time.
# Setting wait=True will queue up additional commands. False will raise MaxConcurrencyReached
# Checks can be stacked, and will Raise a CheckFailure if any check fails.โ
``` check this ;)
Here you have got all checks
how to remove cogs properly
are nukebots allowed in this topic?
No. Nukebots violate Discord's ToS & the API ToS so we will not help with them here
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
!d discord.ext.commands.Command.reset_cooldown you can implement this so in the except block add ctx.command.reset_cooldown(ctx)
reset_cooldown(ctx)```
Resets the cooldown on this command.
guys, how do i get an answer to a question asked by the bot in dm, with which command?
If you have not understood, I want that when a user asks that particular question to the bot and the user answers with "Yes", an embed appears in my specific channel saying <user> has tried to ask the question and has answered (Yes or No)
hi, how can i get the mentioned member's account creation date? also how do i put in a user's id. ik it has to do something with args and stuff but idk how
okay uhh
She said cooldowns not checks sir.
Ohh sory
Is this the correct way of doing this? https://discordpy.readthedocs.io/en/latest/ext/commands/api.html?highlight=on_command_error#discord.ext.commands.BadArgument
if isinstance(error, commands.BadArgument):
if isinstance(error, commands.MemberNotFound):
use class.created_at
i am tryna make a discord bot for the first time, this is my code its giving me errors
import os
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startwith('>hello'):
await message.channel.send('Hello!!')
my_secret = os.environ('TOKEN')
print(my_secret)```
indentations
on line 8? bcuz its giving me error there
theres no error on line 8
which line than, never done coding
2 last lines :)
ya i see a blue circle on line 20
wait
aaahhhh i can't figure this button shit out ;-;
i-i cant find the mistake me dumby
!d discord.ext.commands.Cooldown.reset
last two lines.. indents..
How to localize discord bot using gettext? (Users can select bot's language on their servers)
.
import os
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startwith('>hello'):
await message.channel.send('Hello!!')
my_secret = os.environ('TOKEN')
print(my_secret)```
on line 19 error
something about indentation
^
i used ur code
new error
os.environ is a dict, so you'd do my_secret = os.environ.get('TOKEN') or my_secret = os.environ['TOKEN']
remove the space behind my_secret = os.environ['TOKEN']
now it just putted my bot token at the shell but it didnt come online
thanks man
yes, you forgot a client.run(my_secret) at the end of the file
it worked man ๐
dont spoonfeed him I already said that to him
def init(self, bot):
self.bot = bot
self.song_queue = {}
self.setup()
def setup(self):
for guild in self.bot.guilds:
self.song_queue[guild.id] = []
before i remove the cogs it still usable
@boreal ravine
the bot is online but its not responding to my >hello
can you give your code?
import os
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startwith('>hello'):
await message.channel.send('Hello!!')
my_secret = os.environ['TOKEN']
print(my_secret)
client.run(my_secret)```
^
u are watching freecodecamp right?
if message.content.startswith('>hello")
yee i know it
i am starting so yea
not a good option
did you read my answer?
idk i started with freecodecamp :)))))))))
i remove cogs and this happened. can anyone fix?
i did too, but there are outdated
discord rewrite is better
code
how can i insert code?
@bot.command()
async def queue(ctx): # display the current guilds queue
if len(song_queue[ctx.guild.id]) == 0:
return await ctx.send("Let me see... No song.")
embed = discord.Embed(title="Song Queue", description="", colour=discord.Colour.red())
i = 1
for url in song_queue[ctx.guild.id]:
embed.description += f"{i}) {url}\n"
i += 1
embed.set_footer(text="End of queue.")
await ctx.send(embed=embed)
use after and before the code ```
so does it worked?
async def queue(ctx): # display the current guilds queue
if len(song_queue[ctx.guild.id]) == 0:
return await ctx.send("Let me see... No song.")
embed = discord.Embed(title="Song Queue", description="", colour=discord.Colour.red())
i = 1
for url in song_queue[ctx.guild.id]:
embed.description += f"{i}) {url}\n"
i += 1
embed.set_footer(text="End of queue.")
await ctx.send(embed=embed)```
its more readable now, just a second
where did u define the song_queue variable?
i got indenation error
Is there a certain check to ignore dm messages?
I want to use It in an on_message (level cmd)
send SS AGAIN
huh?
I have a on message (xp) event ant I want It to ignore dm messages but what do I use for that?
if message.channel = private.channel:
return
I currently have this but It doesnt work xd
if ctx.channel.name == "last-to-chat":
embed = discord.Embed(
title = '',
description = '',
colour = 0
)
embed.set_footer(text='By oSeatch#6969')
embed.add_field(name='Disqualified!', value=f"{ctx.author} Has Lost!", inline=False)
channel1 = client.get_channel(890476025996275732)
guild = ctx.guild
rol1e = discord.utils.get(guild.roles, name="susmommuted")
await channel1.send(embed=embed)
await ctx.author.add_roles(rol1e)
return``` how do i make it so that the code won't effect bots
or a specific user in general
for guild in bot.guilds:
song_queue[guild.id] = []```
send me a screenshot of the on_message event, i am sure i can help u on this
make sure you indent correctly
i see
the second if statement is wrong indented
i dont use on_message
its inside the first if statment
anyone?
bro, umm i dont think i can help u with a music bot sorry
title and description cant be empty
well they work for me, so i leave them empty lmao
I am dumb
idk people tell me this alot but for some reason it never breaks for me
so can anyone help?
๐คฃ
whats the error?
ah 1 sec
kk
i asked for error
i send a message, it adds the role and says that i have lost, its all good till then but the bot reacts to its own message
OH
Check if the author's ID is equal to the ID of the user you want to ignore. In case you don't know, ctx.author returns a discord.Member object.
there is no error, its just a bug u could say
!d discord.Member
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User").
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.
hash(x) Returns the memberโs hash.
str(x) Returns the memberโs name with the discriminator.
You can even make a custom check.
its because, u didnt add an if statement prolly
!customcheck
Custom Command Checks in discord.py
Often you may find the need to use checks that don't exist by default in discord.py. Fortunately, discord.py provides discord.ext.commands.check which allows you to create you own checks like this:
from discord.ext.commands import check, Context
def in_any_channel(*channels):
async def predicate(ctx: Context):
return ctx.channel.id in channels
return check(predicate)
This check is to check whether the invoked command is in a given set of channels. The inner function, named predicate here, is used to perform the actual check on the command, and check logic should go in this function. It must be an async function, and always provides a single commands.Context argument which you can use to create check logic. This check function should return a boolean value indicating whether the check passed (return True) or failed (return False).
The check can now be used like any other commands check as a decorator of a command, such as this:
@bot.command(name="ping")
@in_any_channel(728343273562701984)
async def ping(ctx: Context):
...
This would lock the ping command to only be used in the channel 728343273562701984. If this check function fails it will raise a CheckFailure exception, which can be handled in your error handler.
Anyways, i forgot to ask my own problem lol
is there a way to download images using the link of the image specified by the user?
if ctx.channel.name == "last-to-chat":
embed = discord.Embed(
title = '',
description = '',
colour = 0
)
embed.set_footer(text='By oSeatch#6969')
embed.add_field(name='Disqualified!', value=f"{ctx.author} Has Lost!", inline=False)
channel1 = client.get_channel(890476025996275732)
guild = ctx.guild
rol1e = discord.utils.get(guild.roles, name="susmommuted")
await channel1.send(embed=embed)
await ctx.author.add_roles(rol1e)
elif ctx.author == bot:
return``` should this work?
do u think i know how to indent?
try once
yes. everyoe who learn python should knows how to indent.
it simply adds the role when it doesnt need to and reacts to the wrong message, right?
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
๐
you obviously dont know basic python
do u think i know how to use pythonk (no)
i want to make it so that the bot can bypass the code
i cant spell
guys, how do i get an answer to a question asked by the bot in dm, with which command?
If you have not understood, I want that when a user asks that particular question to the bot and the user answers with "Yes", an embed appears in my specific channel saying <user> has tried to ask the question and has answered (Yes or No)
Yes you can
send the whole command ๐ฅฒ , i cant figure it out just with a piece with missing statements
learn python first please
@client.event
async def on_message(ctx):
if ctx.channel.name == "last-to-chat":
embed = discord.Embed(
title = '',
description = '',
colour = 0
)
embed.set_footer(text='By oSeatch#6969')
embed.add_field(name='Disqualified!', value=f"{ctx.author} Has Lost!", inline=False)
channel1 = client.get_channel(890476025996275732)
guild = ctx.guild
rol1e = discord.utils.get(guild.roles, name="susmommuted")
await channel1.send(embed=embed)
await ctx.author.add_roles(rol1e)
elif ctx.author == client:
return``` this the whole thing
omg
need some help
ik that i have absolutely no clue what to do here
tbh, i dont understand what u are trying to do, im really sorry
i think it should use the wait_for event
yes, but how
i have read the documentation but i can't
do u think i know ๐ฅฒ
wait
sad
!d discord.Client.wait_for ^
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
me dumb
.help
how do I then connect it with all the questions?
why not make 2 buttons and make your work easier?
bruh I'm not understanding anything
wait_for waits for an event to dispatch , you can use client.wait_for("message") to get a reply from a user in a command
your a python programmer but cant understand simple documentation?
Like just add two buttons with your message which the user can click and then u can just get the answers the easy way
what ๐ฅฒ
help me plssssssss
im not saying this
send one of your commands
!d discord.on_member_remove
discord.on_member_join(member)``````py
discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
on_member_remove event
wait
the prefix is {message.prefix}
now message doesnt have a prefix
so wht shld i do?
do bot.prefix
i dont understand your question, maybe someone else can help, me dumb
How do I prevent this ?
@dapper cobalt ```py
@client.event
async def on_message(ctx):
bot1221 = #if i add the bot's id here will it work?
if (ctx.channel.name == "last-to-chat" and not ctx.author(bot1221)):
embed = discord.Embed(
title = '',
description = '',
colour = 0
)
embed.set_footer(text='By oSeatch#6969')
embed.add_field(name='Disqualified!', value=f"{ctx.author} Has Lost!", inline=False)
channel1 = client.get_channel(890476025996275732)
guild = ctx.guild
rol1e = discord.utils.get(guild.roles, name="susmommuted")
await channel1.send(embed=embed)
await ctx.author.add_roles(rol1e)``` you think this will work? *sorry for the ping but u seem like the only one who knows what im trying to do*
can someone tell me how to make a thread from a message using discord.py please ??
@commands.Cog.listener()
async def on_message(self,message):
if message.content=="@Chad#6621":
embed=discord.Embed(title="I have been summoned!!",color=discord.Color.random(),description=f"My Prefix on this server is `{self.bot.prefix}`\n Simply do {self.bot.prefix}help to see all my commands!")
embed.set_footer('I was chilling until you disturbed me :(')
await message.channel.send(embed=embed)```
You need to call bot.get_prefix(message) iirc
and ctx.author.id != user_id
you can just use the same function you use to get the prefix in command_prefix here
okok
how?
uhh ok smart
im dumb
The same way you call any coroutine lol
someone help here after you guys are done ๐ฅบ and ping me too
but the method tizzy told is better
yea
First of all you have to import py import discord from discord import * fro pm discord.ext.commands import bot
i actually hv a command for tht
using cogs lol
No
That's very wrong lol
Well if he using cogs then
Even without cogs that's very wrong
Works for me tho ? :/
You shouldn't be doing a star-import (bad practice), and you need bot to be your defined instance of the Bot class, not the file
@commands.Cog.listener()
async def on_message(self,message):
if message.content=="@Chad#6621":
prefix=command_prefix
embed=discord.Embed(title="I have been summoned!!",color=discord.Color.random(),description=f"My Prefix on this server is `{prefix}`\n Simply do {prefix}help to see all my commands!")
embed.set_footer('I was chilling until you disturbed me :(')
await message.channel.send(embed=embed)```
not defined
Read what I said fgs
How is that at all what we told you to do
You need to call the get_prefix method of your bot, passing a message argument
I know that bro what he can do โbot=commands.bot(command_prefixโ@โ)โ please correct me if I am wrong
That is wrong
Very wrong lol
Ok tell me
no then it wld only work on @
commands.Bot (uppercase because it's the class not the file) and ="@"
Tizzy is pissed sorry I am just lurking around :(
async def determine_prefix(bot, message):
if message.guild:
db = TinyDB('databases/prefix.json')
if message is not None:
guild_id = message.guild.id
query = Query()
if db.search(query['guild_id'] == str(guild_id)):
values = list(map(lambda entry: entry["prefix"], db.search(
query.guild_id == str(guild_id))))
return values
return '!'
else:
return '!'```
hows this?
mr tizzy
can u tell HOW to fix it?
Stop and read what I'm telling you to do
bruh im not understanding
^ @gloomy coral
can someone tell me how to make a thread from a message using discord.py please ?? ๐ฅบ
wdym of my bot
If you cannot understand "call this function" then you really shouldn't be doing a discord bot
whats better? discord.utils or guild.get?
which function and where do i call it
guild.get
Ok but what I do is usually import it directly in to like py -3.9 -m pip install module and I know thatโs bad but hey
Read what I said ๐คท
okay
or just make a variable and store the prefix there
sry for wasting ur time tizzy
#discord-bots message also can some body help me with this I will send the code later
how to make this timestamps using bot ? 
class.created_at.timestamp
nah not that the dynamic timestamp thing
which shows time when we hover on that
can someone tell me how to make a thread from a message using discord.py please ?? someone help ๐ฅบ
what do you want then..
code : ```py
@Buttons.click
async def y (ctx):
send=discord.Embed(color=0x51ed87)
send.add_field(name="Action Confirmed", value="Report successfully sent.")
await ctx.message.edit(embed=send)
@Buttons.click
async def n (ctx):
discard=discord.Embed(color=0xed4245)
discard.add_field(name="Action Failed", value="Report discarded")
await ctx.message.edit(embed=discard)``` using module called discord_buttons_plugin for event handler
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
That shows the different formats
Thats what I said tho
any docs that might help me ?? ๐ฅบ
It's not because it's not the formatting
๐ฆ
oh ok thanks a lot
!d discord.Message.create_thread
await create_thread(*, name, auto_archive_duration=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a public thread from this message.
You must have [`create_public_threads`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.create_public_threads "discord.Permissions.create_public_threads") in order to create a public thread from a message.
The channel this message belongs in must be a [`TextChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel "discord.TextChannel").
New in version 2.0.
he said "how do we make timestamps" he didnt specify which
๐คทโโ๏ธ
Ooooo thanks alot thanks alot
.
๐คทโโ๏ธ i mentioned it here
Hey
is @unkempt canyon now updated with the master branch?
This you mean..?
it is
Ic
this returns [!] @bitter depot
!d discord.Member.banner
property banner```
Equivalent to [`User.banner`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.banner "discord.User.banner")
please help me
What seems to be the error
look at the video
I did you clicked the button and it worked
I want to disable the buttons after they have been clicked (Once) or it will flood my inbox @boreal ravine
With discord.py, is it possible to pass a message to the bot (as a string) just to see how that message will be parsed and which command will be run, without actually running the bot in a test-server?
I'm pretty sure you can stimulate events but I don't remember how
Yeah, it'll return a list of all the different prefixes
I see there is bot.invoke, to which you can pass a Context, but I don't know what arguments to give when making a dummy Context ๐
can you give me an example of how to use this ??
i got AttributeError: 'Message' object has no attribute 'create_thread'
I do this at the beginning of my file
_ = Translator()
Where Translator is my own class, which can translate strings. It finds guild's locale using database query. And it works.
But if I have some commands like this
@commands.command()
async def test(self, ctx):
embed = discord.Embed(title=_("Test embed"))
for i in range(5):
embed.add_field(name=_(f"Field number {i + 1}"), value=_("Field's value"))
await ctx.send(embed=embed)
We can see that _ functions are called a lot of times. Every time when I call function _ my translator gets guild's language. But I think I can get guild's language once. How to optimize my code?
If you have an actual discord.Message then there's message.get_context()
Or fetch_context
i wanna make thread of that message
Eh can't remember it lol
You need to be using v2 of dpy
Ooo lemme see
yeah i saw tht by printing type lol
but how can there be more thn 2
on repl its only till 1.7.3 ๐
!d discord.ext.commands.Bot.get_context
await get_context(message, *, cls=<class 'discord.ext.commands.context.Context'>)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Returns the invocation context from the message.
This is a more low-level counter-part for [`process_commands()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.process_commands "discord.ext.commands.Bot.process_commands") to allow users more fine grained control over the processing.
The returned context is not guaranteed to be a valid invocation context, [`Context.valid`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context.valid "discord.ext.commands.Context.valid") must be checked to make sure it is. If the context is not valid then it is not a valid candidate to be invoked under [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").
@visual yarrow ^ if you have a discord.Message you can use this to get the Context
Tizzy can I ask, who is maintaining v2, the master branch? Is it being updated on the rapptz/discordpy github page, as I thought it wasnโt being maintained by Danny anymore. Apologies for singling you out specificallyโฆ
No one is maintaining v2
context.command or context.invoked_parents might be useful
Oh right. But wouldn't that require me to run the bot to get an actual message?
Maybe look at @unkempt canyon's source for tests? Specifically MockContext etc.
I'm looking to test how the bot parses certain messages as commands.
I'll take a look, thanks ๐
So look at discord.ext.commands.bot.Bot.process_commands source code?
I'm not 100% sure what you're after
It's just get_context then invoke
So, I'm not 100% sure how the certain messages will be parsed. Eg where the breaks will be between the arguments will be, which command/subcommand will be run in certain circumstances, etc. And I was looking to test it.
note: the Context might be invalid, to check see Context.valid
Follow through the logic of process_commands ig then
If you want an automated version I'm not too sure
Maybe create a MockMessage which just has all the attrs needed to make a Context (everything that get_context uses)
Then bot.invoke(ctx) ig
so i have this code and it work perfectly. But i want it to make it when the user leaves, it takes away the role
@commands.Cog.listener()
async def on_voice_state_update(self, member, before, after):
if before.channel is None and after.channel is not None:
if after.channel.id == 886331304944214077:
for guild in self.client.guilds:
role_id = 891274340438532136
role = get(guild.roles, id=role_id)
logschannel = self.client.get_channel(886331433134727178)
channel2 = await guild.create_voice_channel(name='๐ Support')
await channel2.set_permissions(member, connect = True)
await channel2.set_permissions(guild.default_role, connect = False, view_channel = False)
await member.move_to(channel2)
await logschannel.send(f"**ฮ {member.mention} ฮผฯฮฎฮบฮต ฯฯฮฟ Support!**")
await member.add_roles(role)
and i have NO IDEA how
!d discord.on_voice_state_update
discord.on_voice_state_update(member, before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") changes their [`VoiceState`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceState "discord.VoiceState").
The following, but not limited to, examples illustrate when this event is called...
Uhhh, I forgot. What do the after and before refer to?
Before the voice state updated and after the voice state updated
Probably
class discord.VoiceState```
Represents a Discord userโs voice state.
!d discord.VoiceState.channel
The voice channel that the user is currently connected to. None if the user is not currently in a voice channel.
Check if its None
So this will be after.channel
@slate swan
Something like
if after.channel is None:
. . . . (Remove roles)
hey
i want to determine that the message author has permissions to kick member or not
in a if
if all((
member.guild_permissions.kick_members,
member.top_role > person.top_role,
member.guild.me.guild_permissions.kick_members,
member.guild.me.top_role > person.top_role
)):```
and determine that the bot has permissions to kick member or not
Edited
if guild.me.guild_permissions.kick_members:
. . . .
Should do it
You also need to check top_role
And same for the author
Ah, yea... I was referring to the second message
Would still need to add this
Yea
First two are that member would be able to kick person
Last two are that the bot would be able to kick person
@fading harness
You may want to make it into a util function
thanks
i didnt make help command :)))
if can_kick(author, person) and can_kick(bot, person):```or something
whatcha trying to do
import discord
from discord.ext import commands
client = commands.Bot(command_prefix = '.')
@client.event
async def on_ready():
print("Bot is ready.")
@client.command()
async def hello(ctx):
myembed = discord.Embed(title="$name.logo", color=0x1fa3d8)
myembed.add_field(name="hello there", value='''
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ''', inline=False)
await ctx.send(embed=myembed)
client.run("TOKEN")
``` @full lily
import discord
from discord.ext import commands
client = commands.Bot(command_prefix = '.')
@client.event
async def on_ready():
print("Bot is ready.")
@client.command()
async def hello(ctx):
myembed = discord.Embed(title="$name.logo", color=0x1fa3d8)
myembed.add_field(name="hello there", value='''
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ''', inline=False)
await ctx.send(embed=myembed)
client.run("TOKEN") # unindented
Though if you're struggling with indentation you might wanna have some more practice with python before attempting a disc bot
i wanna practice by making one
better projects than a discord bot exist for "practise"
!projecrs
Kindling Projects
The Kindling projects page on Ned Batchelder's website contains a list of projects and ideas programmers can tackle to build their skills and knowledge.
There
yes
Very bad
discord module is a bit too advanced for that
That's what I did but I know bad thing
ah
Is here a channel where i can ask for help in me dashboard
it's like saying to someone with no coding experience to make an ML project.
but how do i fix it
Aaaa thx
I used to solve problems in OJs using python then thought maybe make some projects
Bro... ML is more difficult than discord bots
Not me. Never learnt Python but learn dpy first...
If it's regarding discord/ login, IPC routes and parsing using discord here is fine, anything else use #web-development
ML is not that far off.
whats an ML
Machine learning
Machine Learning
Machine L
For beginners, at least discord.py is achievable (I myself started my python journey by not learning basic Python but dpy so I know about it), but ML is some next level shit
discord.on_guild_join(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") is either created by the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") or when the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") joins a guild.
This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
ML is not next level, the issue is with people wanting to do things that are way too difficult small things like facial recognition is very doable.
anyone online?
46k + people
46k+ people online here
rn
And many more is online but just set the status to invisible just like me
!d discord
In order to work with the library and the Discord API in general, we must first create a Discord Bot account.
Creating a Bot account is a pretty straightforward process.
why is this happend?
Because you tried to index a list thats out of range?
the message has no reactions on it
or that
so what i need to fix?
Its your code
@slate swan this?
...
Did it add a reaction
yes
still..
the message is not cached probably
:3
so what i need to do
try printing gaw_message in bot.cached_messages
oh I see
have you enabled intents.reactions?
!d discord.Intents.reactions
Whether guild and direct message reaction related events are enabled.
This is a shortcut to set or get both guild_reactions and dm_reactions.
This corresponds to the following events...
^^ @shrewd dragon

you can see here the changes https://gist.github.com/apple502j/f75b4f24652f04de85c7084ffd73ec58
Ty
So this is the code as you can see when a user requests to become server staff the bot sends all the format, then there are the commands "d1" and response1
I want answer 1 (including all other questions)
is sent in a dedicated channel with an embed, which says the username, and what answers it gave
import discord
from discord.ext import commands
client = commands.Bot(command_prefix = '.')
@client.event
async def on_ready():
print("Bot is ready.")
@client.command()
async def embed(ctx):
embed=discord.Embed(title="A Warm Welcoming.", description="Hey, I am Cogi, nice to meet you.", color=0x000000)
await ctx.send(embed=embed)
embed.set_author(name="Cogi"", url="https://twitter.com/RealDrewData, "Cogi")
embed.set_thumbnail(url="https://cdn.discordapp.com/attachments/891076562206736397/891261099289247794/image0.jpg")
embed.add_field(name="What can I do for you..?", value="I can do a lot for you, actually. This is for you too find out.", inline=False)
@client.command()
async def hello(ctx):
myembed = discord.Embed(title="logo", color=0x1fa3d8)
myembed.add_field(name="hello there", value='''
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ''', inline=False)
await ctx.send(embed=myembed)
client.run("TOKEN")
will this code work?
need some help
unexpendant indent ??
where
idk
it says
how its possible to use json... like for a custom prefix or updating a variable...
A JSON file is like a text file which holds a dictionary.
You can use the json library to work with JSON files.
Or even from strings containing JSON data
ik, but how can I w or r it
Yes
If you can think of a way of doing it with a dictionary, you can think of a way to do it with JSON.
can i have the bot that helped you?
Thats mine tho
how do i make one ๐ฅฒ
Well theres tutorials
whatโs the bot called?
what bot
your bot, what would you call it?
discord.on_guild_remove(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") is removed from the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
This happens through, but not limited to, these circumstances...
@potent jetty this maybe?
I call my bot my bot
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
So this is the code as you can see when a user requests to become server staff the bot sends all the format, then there are the commands "d1" and response1
I want answer 1 (including all other questions)
is sent in a dedicated channel with an embed, which says the username, and what answers it gave
confusing
meaning?
i don't know what to type down
it isn't a video
yes, it isn't a video, its a webguide, its good tho, a pydis staff member made it
guys when i write .rps rock its ok for my bot and it works but when i write .rps Rock or something it just dosen't answer
@client.command()
async def rps(ctx , player_choice):
username = str(ctx.author).split('#')[0]
user_message = str(ctx.message.content)
channel = str(ctx.channel)
choices = ['rock','paper','scissors']
bot_choice = random.choice(choices)
if player_choice.lower() not in choices :
my code
str.lower()```
Return a copy of the string with all the cased characters [4](https://docs.python.org/3.10/library/stdtypes.html#id15) converted to lowercase.
The lowercasing algorithm used is described in section 3.13 of the Unicode Standard.
can anyone help me out
@visual islandi did not understand your info
how do i make a bot ?
click the link, then you'll see a full walkthrough of making a bot account
i did
i did
but did not understand it
show the full code
how
i did everyhting it said me to
It hasnt even get to the hardest thing
then?
async def rps(ctx , player_choice):
username = str(ctx.author).split('#')[0]
user_message = str(ctx.message.content)
channel = str(ctx.channel)
choices = ['rock','paper','scissors']
bot_choice = random.choice(choices)
if player_choice.lower() == bot_choice.lower() :
await ctx.send(f'Tie ! We Both Picked {player_choice} .')
elif (player_choice.lower() == 'Rock' and bot_choice.lower() == 'Scissors') or (player_choice.lower() == 'Scissors' and bot_choice.lower() == 'Paper') or (player_choice.lower() == 'Paper' and bot_choice.lower() == 'Rock') :
await ctx.send(f'You won ! but this is not going to happen again . My choice was {bot_choice} .')
elif (player_choice.lower() == 'Rock' and bot_choice.lower() == 'Paper') or (player_choice.lower() == 'Scissors' and bot_choice.lower() == 'Rock') or (player_choice.lower() == 'Paper' and bot_choice.lower() == 'Scissors'):
await ctx.send(f'Haha You lose ! My Choice was {bot_choice}')
else :
await ctx.send('Oh ! You Did a Typo , Try Again Please !')
return```
now@visual island
i want it to say hi when i say
so like if i say hi the bot should say hello
send a message on my DM
i will teach you
Hi, so I have a bad word blocker but here's my issue. I have this content count thing I want to do but here's the issue.
The bot's only counting the same word. if I say fuck fuck it counts it twice. BUT, if I say fuck shit it counts it once. Here's the code for the content count
embed.add_field(name="Content count", value=message.content.count(word), inline=False)
player_choice.lower() will be lower cased, you're comparing it with "Rock" which will never be True
yeah fixed thanks
Anyone?
yeah ?
whats word
I'm getting each word from the blacklist which I defined as the file. blacklist is the file and I'm getting each word in the file. (I have that above my code. I didn't send it here though)
value = {word: message.content.count(word)}
```I have no idea what type word is, but try this
and can you show your full code
Still the same outcome. The only difference is it now shows the word with the amount of the same word.
yeah, let me dm you it
just send it here
say what
if user_list is a list of ids yes
ok
just coded a full project that has over 50 commands
you mean youโreโฆgoing to make it public like 90% of discord bots?
is this some huge announcement
even has ip lookup and portscanning tools
okay
you mean youโฆfound an api/module
port scanning is easy
you want a medal or something?
how do you make it crack an IP
like sending a ddos attack ?
do you expect people to make a countdown and stay up all night to wait for the big unveil of your bot with โฆ 50 commands?
sure
its for your on use correct no harm ?
I need help at here, it says Command raised an exception: AttributeError: 'str' object has no attribute 'id' ```py
@client.command()
@commands.has_permissions(administrator=True)
async def prefix(ctx, prefix):
with open("prefixes.json", "r") as f:
prefixes = json.load(f)
prefixes[str(guild.id)] = prefix
with open("prefixes.json", "w") as f:
json.dump(prefixes, f)```
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
just check dms
i was kidding
guild is a string
is guild a pre defined / global variable?
i think you want ctx.guild
^^
who tho
Hey i have problem i want make command help with changing page with reactions
problem is visible on video (sorry for quality)
and this is a code
https://hastebin.com/mejosaviqe.py
that is in event on_message
was for Juu
sorry not who, why
i recommend just using prettyhelp
Eh, im doing a custom prefix... but for a guild mainly
what?
!pypi discord-pretty-help
And nicer looking interactive help menu for discord.py
what is it
you probably need a while loop
it automatically makes a help command for you
you may use ctx.guild
I think better is to make one yourself
uhm
json is not actually a database , it can get corrputed easily
not if youโre a beginner, also, you can just edit the source code if you realllllly need it to be unique
ye and i don't know how i can do it good
the X emoji exits the help prompt right?
yes it just delete message
# PARAMETER ============================================================================================================
def get_prefix(client, message):
with open("prefixes.json", "r") as f:
prefixes = json.load(f)
return prefixes[str(message.guild.id)]``` ```py
# PREFIX ===============================================================================================================
@client.event
async def on_guild_join(guild):
with open("prefixes.json", "r") as f:
prefixes = json.load(f)
prefixes[str(guild.id)] = "$"
with open("prefixes.json", "w") as f:
json.dump(prefixes, f)
@client.command()
@commands.has_permissions(administrator=True)
async def prefix(ctx, prefix):
with open("prefixes.json", "r") as f:
prefixes = json.load(f)
prefixes[str(guild.id)] = prefix
with open("prefixes.json", "w") as f:
json.dump(prefixes, f)``` Only my command isn't working :/
it might be a bit complicated
I'm trying to understand it
i mean , you cannot convert a non numerical string to int
it maybe be because the audio playing at the moment is a live stream
also , ytdl is against tos so cant help further
Hello. Is it possible for a command to take arguments, but also have subcommands?
you can ofcourse do that
it will not take the arguments with same value as the sub command name tho
I mean, using bot.group, without having to parse the subcommand myself.
Oh right. So the default behaviour is to try to subcommand first, then fall back to the command group?
yeah exactly
can i ask someone that knows python really well a question in dms
not here
iirc there is the invoke_without_subcommand kwargs or something like that
anyone?
is it True by default?
ok just checked its invoke_without_command
Hmm, with the following code, when I try invoking !foo bar, I get 'foo' command run with arg 'bar'. ```py
from discord.ext import commands
from discord.ext.commands import Context, Bot
import discord
import config
import logging
logging.basicConfig()
logger = logging.getLogger(name)
logger.setLevel(logging.INFO)
bot = Bot(commands.when_mentioned_or('!'))
@bot.group()
async def foo(ctx: Context, *, arg: str = ''):
logger.info(f"'foo' command run with arg {arg!r}")
@foo.command()
async def bar(ctx: Context, *, arg: str = ''):
logger.info(f"'foo bar' command run with arg {arg!r}")
bot.run(config.token)
discord/ext/commands/core.py line 1408
self.invoke_without_command: bool = attrs.pop('invoke_without_command', False)```
you need to add invoke_without_command=True in the bot.group decorator
Right. I'll try that. Thanks! ๐
Success ๐
it is what you think?
@hasty iron ?
guys, how do i get an answer to a question asked by the bot in dm, with which command?
If you have not understood, I want that when a user asks that particular question to the bot and the user answers with "Yes", an embed appears in my specific channel saying <user> has tried to ask the question and has answered (Yes or No)
!d discord.Member.send use this to send a dm
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
and use wait_for('message') to get the answer
i already answered you what you need to do
Hello! Probably not right channel... But the best I could find. The question is: Where is the best and cheap servers for a Discord bot and other python things?
Hey @knotty lagoon!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
โข If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
โข If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
@pastel torrent
yes but how do I connect everything
use it with the correct indents
that was just an example not to be copy pasted
indents are correct
i need some help
@slate swan
please 
send the code you have rn
how does the wait_for method work?
where is the cheapest?
Can you put a button inside a embed
how
import discord
from discord.ext import commands
client = commands.Bot(command_prefix = '.')
@client.event
async def on_ready():
print("Bot is ready.")
@client.command()
async def embed(ctx):
embed=discord.Embed(title="A Warm Welcoming.", description="Hey, I am Cogi, nice to meet you.", color=0x000000)
await ctx.send(embed=embed)
embed.set_author(name="Cogi")
embed.set_thumbnail(url="PIC")
embed.add_field(name="What can I do for you..?", value="I can do a lot for you, actually. This is for you too find out.", inline=False)
@client.command()
async def hello(ctx):
myembed = discord.Embed(title="logo", color=0x1fa3d8)
myembed.add_field(name="hello there", value='''
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ''', inline=False)
await ctx.send(embed=myembed)
client.run("TOKEN")
WHAT TO FIX, MY CODE WON'T WORK
๐ฅฒ
WHAT IS THE ERROR
UH
@soft trout u can help me with this button
huh?
yes
yes
@client.event
async def on_ready():
print("Bot is ready.")
@client.command()
async def embed(ctx):
embed=discord.Embed(title="A Warm Welcoming.", description="Hey, I am Cogi, nice to meet you.", color=0x000000)
await ctx.send(embed=embed)
embed.set_author(name="Cogi")
embed.set_thumbnail(url="PIC")
embed.add_field(name="What can I do for you..?", value="I can do a lot for you, actually. This is for you too find out.", inline=False)
i am looking
indentation is wrong
yeah
i don't know what an indentation is
therefore i must seek help from professionals ๐
you should try easier subjects before doing discord bots
i know, i'm trying to learn through bots, what do i fix tho, and what did i do wrong
embed.set_author(name="Cogi")
embed.set_thumbnail(url="PIC")
embed.add_field(name="What can I do for you..?", value="I can do a lot for you, actually. This is for you too find out.", inline=False)
``` this has to be on the same level as the other code
so like
as in?
@commands.command()
async def mybutton(self, ctx):
view = View()
view.add_item(Button(label="button", custom_id="my_button",row=1))
await ctx.send("Your board", view=view)
await self.client.wait_for(view.interaction_check(), check=None)
await ctx.send("Button Pressed!")
```What am I doing wrong? why won't it work?
woops
@client.event
async def on_ready():
print("Bot is ready.")
@client.command()
async def embed(ctx):
embed=discord.Embed(title="A Warm Welcoming.", description="Hey, I am Cogi, nice to meet you.", color=0x000000)
await ctx.send(embed=embed)
embed.set_author(name="Cogi")
embed.set_thumbnail(url="PIC")
embed.add_field(name="What can I do for you..?", value="I can do a lot for you, actually. This is for you too find out.", inline=False)```
why you sending the embed before you add the author and thumbnail?
thats not mine tho
yes
if you want to do it this way, you'd need to edit the message afterwards, something like:
..<before code>..
await ctx.ed(embed=embed)
so
Anyway. can someone help me with buttons? ;-;
await ctx.ed(embed=embed)
@client.event
async def on_ready():
print("Bot is ready.")
@client.command()
async def embed(ctx):
embed=discord.Embed(title="A Warm Welcoming.", description="Hey, I am Cogi, nice to meet you.", color=0x000000)
await ctx.send(embed=embed)
embed.set_author(name="Cogi")
embed.set_thumbnail(url="PIC")
embed.add_field(name="What can I do for you..?", value="I can do a lot for you, actually. This is for you too find out.", inline=False)
!pypi dislash
Well. I've never used "wait_for" before. nor have I used buttons or the interaction. so idk how to catch the button
@drifting arrow https://pypi.org/project/dislash.py/
You'd be wrong
indeed
If there wasnt anything wrong with the code I wouldnt be here
ik
await self.client.wait_for("my_button", check=view.interaction_check())
TypeError: interaction_check() missing 1 required positional argument: 'interaction'
Can I use dislash with discordpy?
Coz I dont particularly feel like remaking my bot
test
Test successful.
!indent
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
??
fix your indent
wdym
the indentation is wrong
what do I put there instead
there is a tag which explains it
its an indent error literally right there
!indent
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
dpy is very advanced so you might wanna learn basic python first
Anyone know how I can fix this error?
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\user\OneDrive\Desktop\Profanity Blocker\main.py", line 924, in on_message
embed.add_field(name="Content count", value = {word: message(word) for word in test2 if regex_match_true.search(message.content) and regex_match_none.search(message.content) is None(word) != 0}) File "c:\Users\user\OneDrive\Desktop\Profanity Blocker\main.py", line 924, in <dictcomp>
embed.add_field(name="Content count", value = {word: message(word) for word in test2 if regex_match_true.search(message.content) and regex_match_none.search(message.content) is None(word) != 0})TypeError: 'NoneType' object is not callable```
Code:
symbols = string.punctuation + string.digits + "โ"
letters = string.ascii_letters + "โ"
with open("test.txt") as file:
test2 = file.read().split('\n')
@bot.listen("on_message")
async def on_message(message):
guild = message.guild
bypassedRole = discord.utils.get(guild.roles, name="Bypassed")
if bypassedRole in message.author.roles:
return
for word in test2:
regex_match_true = re.compile(fr"[{symbols}]*".join(list(word)), re.IGNORECASE)
regex_match_none = re.compile(fr"([{letters}]+{word})|({word}[{letters}]+)", re.IGNORECASE)
if regex_match_true.search(message.content) and regex_match_none.search(message.content) is None:
await message.delete()
embed = discord.Embed(title="Message Deleted", color=0xD708CC, description= f"{message.author.mention}, You're not allowed to say that.")
embed.timestamp = datetime.utcnow()
await message.channel.send(embed=embed)
the_guild = message.guild
the_channel = discord.utils.get(the_guild.text_channels, name="badword-logs")
the_author = message.author
embed = discord.Embed(title="Bad Word Blocked", description=f"{message.author.mention} sent a bad word", color=15158332)
embed.add_field(name="Blocked Message", value=f"{message.content}", inline=False)
embed.add_field(name="Channel", value=f"{message.channel.mention}", inline=False)
embed.add_field(name="Content count", value = {word: message(word) for word in test2 if regex_match_true.search(message.content) and regex_match_none.search(message.content) is None(word) != 0})
embed.timestamp = datetime.utcnow()
await the_channel.send(embed=embed)```
Anyone know the issue?
How do I get the permissions of a user on a server
!d discord.Member.guild_permissions
property guild_permissions: discord.permissions.Permissions```
Returns the memberโs guild permissions.
This only takes into consideration the guild permissions and not most of the implied permissions or any of the channel permission overwrites. For 100% accurate permission calculation, please use [`abc.GuildChannel.permissions_for()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel.permissions_for "discord.abc.GuildChannel.permissions_for").
This does take into consideration guild ownership and the administrator implication.
that returns the permissions integer I think
Ohh, Iโm not at my house right now. But when I fix that will it work?
Sure
Yups
So it will?
He can do dict()
why when i add reaction โฌ ๏ธ it not work?
Here's code
https://hastebin.com/hajiquqesu.py
Bruh, yea
and sorry for quality video
Oh okay, I didnโt know what you meant by โsureโ. I thought you meant it as sarcasmSorry lol
Haha it's fine
someone can help me please ?
anyone know how i could now get something else from the document like the logschannelid thats there?
https://cdn.discordapp.com/attachments/881309496385884180/891347067174268938/unknown.png
Hunter is very good guy. Helpes everyone. The best teacher ever I have seen.
So I like him.
Hmm.... Did ya get the reacthion by using /? Like /๐
And you can get the code of emogi.
If It doesn't work.... or if you already know that than I'm so sorry. I hope it works.
And I can't see your codes with my phone:(
That's all
Does it print that thing in the if statement?
Oh hunter
Hi
Uhhh, cool, ig?
when pylance and python don't get along 
I saw your site. I'd like to make a AI bot like you.
Wait, which site u talking about? I never made any website for my bot
like this site
Yep
Haha I suggest u delete that link from here
It's so good
Thanks ๐
Anyways, it is ot.. Let's go to #ot0-psvmโs-eternal-disapproval
nvm make it #ot1-perplexing-regexing
Uhh @brazen seal???
Can you wait please? Im busy now
Ah sure
if anyone is good with pymongo lmk as i have a question.
just ask yr question either here or in #databases
wot
tic tac toe? There is an example for the same in the examples directory ๐คฃ
Yea
basicly the _id is the servers id and i want to get another value which is the logs channel id but how do i do this just knowing the _id
oops didnt mean to reply to you
it is fine, I don't mind pings
@dusk pumice @drifting arrow
https://github.com/Rapptz/discord.py/blob/master/examples/views/tic_tac_toe.py
Don't copy the code please, take an idea from it
Take care!
Tnx
And I guess U know something about discord slash command? Do you have any sample codes?
My code doesn't work.
you using a fork of discord.py or?
Me just importing it and using anothor thing like discord-py-slash-command
ah
If import is fork than I can say yes
Well, I haven't made an advanced slash command, but I have made a simple privacy policy slash command
discord.py doesnt have support for slash commands, but forks like disnake have support for it
yea
^^^
so i'm using discord-py-slash-commands
i know pycord has slash commands and buttons:
https://pycord.readthedocs.io/en/master/api.html#discord.Bot.slash_command
I have made slash command, user command, message command and text command for my AI Bot with disnake
idk lets depend on what I find
guess no one knows about my question then ๐
Sorry, I made my own API for database, so I don't know about pymongo
-<
the only thing I know is to use motor cz pymongo is blocking ๐
Welcome to fact or cap where we test-
@maiden fable will probs use this tic-tac-toe thing as the example to do other stuff
lmfao
BTW at last I have add another thing to the bot. Now anyone can talk to the bot in their own language ๐
What the heck is that
a pastebin
you using bing translate?
no
How you translating what they're saying then? You'd need some sort of translator right? or did you just add an alias for all languages? ๐ค
๐คฃ I didn't make my own translator, ofc
you make everything your own hunter?
but you are using some sort of translator right? like google.translate? @maiden fable ?
๐คฃ I didn't make anything by myself in my bot
!pypi async_google_trans_new
Is there any library for trans?
I thonght of selea.... (whatever)
Nope, against ToS
ok
just told u what I am using
opps
Did you not see the line above that?
Yea