#discord-bots
1 messages · Page 449 of 1
Just comment out the lines giving the error and then print it
^
This is line 102: py "For further help, join my  » **[Support Server](...Invite)**\n\n" whats wrong?
https://cdn.discordapp.com/attachments/381965515721146390/883831691460874240/unknown.png
show line 103
you have a non utf8 character in there somewhere
or a part of your code
» this might by a non utf-8 for example
!charinfo »
\u00bb : RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK - »
nvm
\u30fb : KATAKANA MIDDLE DOT - ・
@bot.event
async def on_member_join(member):
await member.guild.get_channel(868696187497234435)
embed = discord.Embed(
title=('welcome to aurora {member.mention}') ,
description= ('Pls read #|rules, #|self-roles, #|roles-info') ,
colour= discord.Colour.dark_green()
)
await ctx.send(embed=embed)
This is my eroor
its supposed to be a welcome message with an embed
i know its the await member.guild.get_channel
wait
let me try soemthing
im moving the await to the bottom
its await for fetch because fetch is api call
@bot.event
async def on_member_join(member):
channel = member.guild.get_channel(868696187497234435)
embed = discord.Embed(
title=('welcome to aurora {member.mention}') ,
description= ('Pls read #|rules, #|self-roles, #|roles-info') ,
colour= discord.Colour.dark_green()
)
await channel.send(embed=embed)
get just searches cache, no await needed
so replace await with get?
just do this? @broken turtle
bye 👋
@opaque trail i got this error
!charinfo ⏮
copy my code.
ctx isnt defined
!charinfo ◀️
\u25c0 : BLACK LEFT-POINTING TRIANGLE - ◀
\ufe0f : VARIATION SELECTOR-16 - ️
\u25c0\ufe0f
im gonna define it real quick and try
just copy my code.
i did
the whole code
I did
no you didnt
!charinfo ⏹
\u23f9 : BLACK SQUARE FOR STOP - ⏹
copy my code and replace it by yours.
i did
!charinfo ▶️
\u25b6 : BLACK RIGHT-POINTING TRIANGLE - ▶
\ufe0f : VARIATION SELECTOR-16 - ️
\u25b6\ufe0f
!charinfo ⏭
can you read?
do not use ableist language or insult other users
same goes for you
also on_member_join takes a single argument
what?? I said are you braindead to someone one time and got a 24 hour mute
please DM @novel apex if you have any questions or comments about moderation
We always take people's history into account. But yeah, message modmail if you think some moderation action is unfair.
well the mutes already been given lol
and often when people make decisions they tend not to change their mind
!charinfo 〢
\u3022 : HANGZHOU NUMERAL TWO - 〢
Do that in #bot-commands
can I run my own instance of the Python bot in my own server? I've cloned the github repo but I can't find where to add my own token for my own bot account
nvm, there's a ton of extra code in there, I'll just look into using the same snekbox api
i have a setup command and am trying to check if the bot has perms.
so far i have something like
if ctx.guild.me.has_permissions(administrator=true):
print("has admin")
else:
print("doesnt")```
on_member_join has ctx?
no
I think you can get a message by its ID from a channel object. So you'd need to get that first
if you are in a command funciton, use my_msg = await ctx.channel.fetch_message(<your msg id>)
if you are in a event function, type my_msg = await message.channel.fetch_message(<id>)
The message ID.
def h(ctx):
if ctx.message.guild == 883762260059754516:
return True
@commands.check(h)
@client.command()
async def test123(ctx):
await ctx.reply('good')
returns
Ignoring exception in on_command_error
discord.ext.commands.errors.CheckFailure: The check functions for command test123 failed.
any clue what's wrong?
ctx.message.guild will return a discord.Guild object not an integer.
Make it ctx.guild.id instead.
whoops rookie mistake
hi can somebody help? idk what's wrong with this embed
embed = discord.Embed(
title="Here's your link",
description=(f"click the link not the green play button\n{link}"),
set_footer(text=('beano')),
color=0x69dab4
)
await ctx.send(embed=embed)
set_footer is an attribute not a method.
hmm so discord.Embed.footer?
Heya, I try to do @quaint axle.event and @quaint axle.command but it doesnt work
or just footer="
How do I fix it?
Why does on_message make my commands stop working?
https://discordpy.readthedocs.io/en/latest/faq.html#why-does-on-message-make-my-commands-stop-working
Ty
File "/Users/dumb_boi/Desktop/discord activities/hax.py", line 33
)
^
SyntaxError: positional argument follows keyword argument
embed = discord.Embed(
title="Here's your link",
description=(f"click the link not the green play button\n{link}"),
embed.set_footer(text="im stonk"),
color=0x69dab4
)
await ctx.send(embed=embed)
hi i'm not sure why it returns this error can somebody help fix? 
embed.set_footer is not supposed to be in the discord.Embed
hmm so do i make a variable and do footer=(ufweafsde)
embed = discord.Embed(
title="Here's your link",
description=(f"click the link not the green play button\n{link}"),
color=0x69dab4
)
embed.set_footer(text="im stonk")
await ctx.send(embed=embed)
oh
What
Set_footer is an attr?

i get this error message when a mute command doesnt have a reason
how can i make it so it send the commands.MissingRequiredArgument error instead of printing that in the output
make a error handler
how to set an image of an embed as an image located in a directory instead of url?
nevermind
😶
i have one
is it possible to make it so a discord bot can delete the server avatar then replace it with another image?
can i get an image attachment from a message using wait_for? if so, how?
i need to convert it to a url so i can store it in a database
Yes
how?
it's uhh possible but sadly I don't remember how because i never had to use it
theres a thing called read the docs
;/
yes
it has almost everything
:)
but the person doesn't know what to search there
isnt it like umm guild.change or something i also forgot lol
rip
haha since most people use it for nuking
thats why the docs are here for ppl to read em
!tag
!tag guild.change
amogus
?
!d discord.Guild
class discord.Guild```
Represents a Discord guild.
This is referred to as a “server” in the official Discord UI.
`x == y` Checks if two guilds are equal.
`x != y` Checks if two guilds are not equal.
`hash(x)` Returns the guild’s hash.
`str(x)` Returns the guild’s name.
op
ohh its guild.edit()
@client.command(pass_context=True)
async def update_ovr(ctx, member: discord.Member, updated_ovr):
updated_ovr = int(updated_ovr)
cursor.execute("SELECT user_ovr FROM main WHERE user_id = (?)",
(member.id, ))
old_ovr_list = cursor.fetchall()
old_ovr = old_ovr_list[0][0]
cursor.execute("UPDATE main SET user_elo = (?) WHERE user_id = (?)",
(int(updated_ovr), member.id))
db.commit()
embed = discord.Embed(
title=f'Ovr Updated!', description = f'{member.mention}, your OVR has been updated!')
embed.add_field(name="Before", value = f'{old_ovr}', inline=True)
embed.add_field(name="Updated", value = f'{updated_ovr}', inline=True)
await ctx.send(embed = embed)
Ignoring exception in command update_ovr:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 128, in update_ovr
old_ovr = old_ovr_list[0][0]
IndexError: list index out of range
i dont get this
old_ovr_list[0] does not have anything in the second list.
Or old_ovr_list does not have anything in the first list.
Try to print old_ovr_list.
#Update Ovr
@client.command(pass_context=True)
async def update_ovr(ctx, member: discord.Member, updated_ovr):
updated_ovr = int(updated_ovr)
cursor.execute("SELECT user_ovr FROM main WHERE user_id = (?)",
(member.id, ))
old_ovr_list = cursor.fetchall()
print(old_ovr_list)
cursor.execute("UPDATE main SET user_elo = (?) WHERE user_id = (?)",
(int(updated_ovr), member.id))
doesnnt do anything
@dapper cobalt
Then print cursor.fetchall().
aight
hmm
@clever wind why pass context
how do i implement slash commands in a discord.py bot
@slate swan use 3rd party libs
i honestly don't know. it doesn't work without it tho so thats why im using it. im using rewrite so i honestly don't know why the code doesn't work without it
dislash provides buttons context menus slash commands and that other one
Not really discord.py related but for a bot. Wondering if anyone knows how to get the time left until a datetime timestamp has passed?
hi
is there a way to get multiple line cmds?
You can use this Discord "trick" to convert timestamps into datetimes <t:rounded_timestamp> and add :R at the end of it (<t:rounded_timestamp:R>) so it would be reversed and show the time left.
you can just use time.time() instead of datetime
can someone make me a regex for a specific word
thanks
also thanks
Yeah that works too.
How can copying a user's Id help with a bot
it can be used to find the user
Oh how?
bot.get_user(the id)
would this regex work for just looking for the word "halloween" while ignoring caps and like numbers that might replace a letter? Like using 1's for L's and whatever
^halloween$```
i mean, ignoring caps you need the re.I flag, but no, that wont see numbers as letters, ya gotta make that yourself
Why does it say in 52 years for me aswell, my timestamp is frmo like five minutes ago?
like, just the word halloween or, i mean this isn't really discord bot related, could've ask in #python-discussion
I mean it is kinda dpy related since im using an on_message event for just this word
Don't use the same code, that was just an example. I did some calculations to increase it.
if this is just for a single word, you would use | which means or, such as this,
h(a|4)(l|1)(l|1)(o|0)w(e|3)(e|3)n
this regex basically see if there is 4 or a, and l or 1 etc, which results in hal1ow3en being match
You then can use this in re.search where it will search for this pattern and with re.I as the flag for ignoring case ```py
re.search(r"h(a|4)(l|1)(l|1)(o|0)w(e|3)(e|3)n", "hal1ow3en", re.I)
<re.Match object; span=(0, 9), match='hal1ow3en'>
yeah i would have never figured that out
Thank you stella
self.halloween_re = re.compile(r"h(a|4)(l|1)(l|1)(o|0)w(e|3)(e|3)n", re.IGNORECASE)```
is re.IGNORECASE needed now?
yea, re.I is just an alias of re.IGNORECASE
sure
who wanna collab in my bots rewrite?
im just starting to rewrite it rn
depends what are you trying to rewrite
eh, an economy bot
if someone's nick is [0] ign and i wanna edit the 0 to 5 how would i do that
im gonna use mongodb
for the database
sure ill help
do you have vscode?
go to dm
lemme join too
sup @vale pendant
i think ur supposed to do ctx, message
No
oh
only message
i am dumb don't listen to me
lmao ok
You get context by await client.get_context(message)
uhh isn't it message.context
!d discord.Message.context
No documentation found for the requested symbol.
See, nothing like that :D
hmm
It is context.message
ok
!d discord.ext.commands.Context.message
The message that triggered the command being executed.
if its in a on_message event do message.author.name or msg.author.name depends on what you put
What's a good software too code it on that is not too complicated to figure out
hi does anybody know which free platforms i should use to host my bot?
Are you a begginer?
yeee
@lofty heron
Oh ok then use replit just search up python how to make discord bot and click the tutorial about replit
i tried replit
No downloads + 24/7
So what happened?
Learn how to code a Discord bot using Python and host it for free in the cloud using Repl.it. Along the way, you will learn to use Repl.it's built-in database and create a Discord bot that uses webhooks to connect with GitHub.
Need help with this tutorial? You can ask questions here: https://forum.freecodecamp.org/
This course was developed by...
Use this
Super simple tutorial
Any help needed, go to the comment sections
ok
ok
did you download the module
not console
do it in shell
yee ik
hi
TypeError: 'int' object is not iterable
whats does it mean
can you tell me
guys
@lofty heron import is like this from discordTogether import DiscordTogether
yeah
can u send code
i got this for my imports

Choose = random.randint(1, 10)
for x in Choose:
if x == 9:
break
else:
Data.append(Choose)
this is it
Hi, how to make inventory for a card game
it means it cannot iterate through "Choose" since its only 1 number
random.randint(1, 10)
will give 1 random number not couple
any good audio filters module for music?
idk i use youtubedl its ok
but i want more features, like bass boost pitch control and more
you could probably search for a music lib on github
hi does anybody know how to add a cooldown to a command?
what is that module for?
discord activities
!d discord.ext.commands.cooldown
discord.ext.commands.cooldown(rate, per, type=<BucketType.default: 0>)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")
A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").
If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.on_command_error "discord.on_command_error") and the local error handler.
A command can only have a single cooldown.
tenks
use this decorator
ok
like for slash commands and interactions?
alr
@reef shell here
so it does detects user activities?
oh
hmm idk why it's not working inreplit
how do i add a bot ban command?
@client.command()
async def ping(ctx):
latency = bot.latency
await ctx.send(latency)
hmm when i do this the bot returns not a number idk why
wait hold on nvm found it
it should send a number
It sends a float
lol changed bot to client
bot ban means people cant use the bot anymore
not server ban command
wdym
i worked for a while then it broke
why when i try add other pages to this it gives error i am trying to add 7 but it only goes to 3
@client.command()
async def embedpages(ctx):
page1 = discord.Embed (
title = 'Page 1/3',
description = 'Description',
colour = discord.Colour.orange()
)
page2 = discord.Embed (
title = 'Page 2/3',
description = 'Description',
colour = discord.Colour.orange()
)
page3 = discord.Embed (
title = 'Page 3/3',
description = 'Description',
colour = discord.Colour.orange()
)
pages = [page1, page2, page3]
message = await ctx.send(embed = page1)
await message.add_reaction('⏮')
await message.add_reaction('◀')
await message.add_reaction('▶')
await message.add_reaction('⏭')
def check(reaction, user):
return user == ctx.author
i = 0
reaction = None
while True:
if str(reaction) == '⏮':
i = 0
await message.edit(embed = pages[i])
elif str(reaction) == '◀':
if i > 0:
i -= 1
await message.edit(embed = pages[i])
elif str(reaction) == '▶':
if i < 2:
i += 1
await message.edit(embed = pages[i])
elif str(reaction) == '⏭':
i = 2
await message.edit(embed = pages[i])
try:
reaction, user = await client.wait_for('reaction_add', timeout = 30.0, check = check)
await message.remove_reaction(reaction, user)
except:
break
await message.clear_reactions()```
das big
huh?
the code is quite big
anyone know how i can format this better?
Why r u uploading a file? That's just extra stress on your processor. Just send a codeblock
iterate through and print the guild name and/or id?
it might be too big
exceeding character limit
Well, I would use Pagination in that case tbh
you don't need to be printing the guild object
Yes
well thats just jishaku
if the output exceeds the char limit it sends in file i think
async for guild in bot.fetch_guilds():
await ctx.send(guild.name)
Don't fetch. Use get. Also get ready to be ratelimited with that loop
true
Cz that would make two API calls on every loop (one to fetch and one to send)
?
hi
why its only generating any single number multiples time
while (True):
a = random.randint(1, 40)
Data.append(a)
for x in Data:
if len(Data) == 10:
break
else:
Data.append(a)
print(Data)
cause the value of a is constant for one loop
wdym
How do I return a users custom status?
!d discord.Member.activity
activity```
Returns the primary activity the user is currently doing. Could be `None` if no activity is being done.
Note
Due to a Discord API limitation, this may be `None` if the user is listening to a song on Spotify with a title longer than 128 characters. See [GH-1738](https://github.com/Rapptz/discord.py/issues/1738) for more information.
Note
A user may have multiple activities, these can be accessed under [`activities`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Member.activities "discord.Member.activities").
not the activity
the status like "[Python] Do not DM for help - please ask publicly."
yes i know
try this
how can i add a thumbnail tho this?
page1 = discord.Embed (
title = 'Santana Introduce Help',
description = f"",
colour = 0x2f3136,```
!d discord.Embed.set_thumbnail
set_thumbnail(*, url)```
Sets the thumbnail for the embed content.
This function returns the class instance to allow for fluent-style chaining.
Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the thumbnail.
so where the url goes?
@spring flax
use the url kwarg for set_thumbnail
so can i use set_thumbnail = f"", ?
i wanna put the guild icon for the thumbnail how i do that?
set_author(*, name, url=Embed.Empty, icon_url=Embed.Empty)```
Sets the author for the embed content.
This function returns the class instance to allow for fluent-style chaining.
The guild’s icon.
embed.set_thumbnail(url=)
prob cause an error
after i click it
it shows the error?
@stark bobcat did your code even have client.run?
same way get the guild icon url with this:
ohhh
!d discord.Guild.icon_url
icon_url```
Returns the guild’s icon asset.
mb sry
or you can use set_author too
@client.command(administrator = True)
async def ticketsetup(ctx):
guild = ctx.guild
tick = discord.Embed(title= "KATSA TICKETS!", description = "React with 🎫 to create a ticket!", color = 0x00F3FA)
tick.set_footer(text="Ticket system created by katsa")
tick.set_thumbnail(url=ctx.guild.icon_url)
clos = discord.Embed(title = "Your ticket is being closed", color = discord.Colour.random())
clos.set_footer(text="Ticket system created by katsa")
await ctx.send(
embed = tick,
components = [
Button(style = ButtonStyle.blue, label = "🎫")
]
)
while True:
event = await client.wait_for("button_click")
label = event.component.label
overwrites = {
guild.default_role: discord.PermissionOverwrite(read_messages=False),
guild.me: discord.PermissionOverwrite(read_messages=True),
event.author: discord.PermissionOverwrite(read_messages=True)
}
if label == "🎫":
channel = await guild.create_text_channel(f"{event.author.name} `s ticket",overwrites = overwrites)
await event.respond(type = 4, content = f"Your ticket has been created at {channel.mention}")
clo = discord.Embed(title= "Welcome to katsa tickets!", description = f" Hello {event.author.mention} Support will be with you shortly!", color = discord.Colour.random())
clo.set_footer(text="To close this ticket click the 🔒")
await channel.send(
embed = clo,
components = [
Button(style = ButtonStyle.red, label = "🔒"),
]
)
event = await client.wait_for('button_click')
label = event.component.label
if label == "🔒":
await event.respond(type = 7, embed = clos)
await channel.delete()``` please someone help . sometimes it creates the channel in another server
@crisp pine
Guild.icon_url
pls help
@spring flax
code?
show code
how does it make it in another guild lol
comma
idk it just make it in another server
i honestly dont believe that
where?
it creates the chann in another server that has the ticket
@spring flax
embed=discord.Embed(title=..., description=..., thumbnail=...., color=....)```
why do you need an f string?
to put the guild icon for the thumbnail ig
you don't have to use an f string
what can i use
wow i messed it up
Hii
example = "test"
this: ```py
x = f"{example}"
is the same as ```py
x = example
@crisp pine ^
lemme try
Helo bro
Hello
Bro where is project section
thumbnail= f"{ctx.guild.icon_url}",```
gives no error but the icon would not show
why error
do you have error handler or on_comamnd_error
show code
no
wdym the icon won't show?
@bot.event
async def on_message(message):
if bot.user == message.author:
return
if message.channel.id==862612779664015373:
response = await rs.get_ai_response(message.content)
await message.reply(response["message"])
await bot.process_commands(message) ```
response is a dict
like the code is there and everything look
see
the guild icon would not show
lemme send it on my atl cause its long
ok here
@client.command()
async def embedpages(ctx):
page1 = discord.Embed (
title = 'Santana Introduce Help',
description = f"",
thumbnail= f"{ctx.guild.icon_url}",
colour = 0x2f3136,
)
page2 = discord.Embed (
title = 'Page 2/3',
description = 'Description',
colour = discord.Colour.orange()
)
page3 = discord.Embed (
title = 'Page 3/3',
description = 'Description',
colour = discord.Colour.orange()
)
pages = [page1, page2, page3]
message = await ctx.send(embed = page1)
await message.add_reaction('⏮')
await message.add_reaction('◀')
await message.add_reaction('▶')
await message.add_reaction('⏭')
def check(reaction, user):
return user == ctx.author
i = 0
reaction = None
while True:
if str(reaction) == '⏮':
i = 0
await message.edit(embed = pages[i])
elif str(reaction) == '◀':
if i > 0:
i -= 1
await message.edit(embed = pages[i])
elif str(reaction) == '▶':
if i < 2:
i += 1
await message.edit(embed = pages[i])
elif str(reaction) == '⏭':
i = 2
await message.edit(embed = pages[i])
try:
reaction, user = await client.wait_for('reaction_add', timeout = 30.0, check = check)
await message.remove_reaction(reaction, user)
except:
break
await message.clear_reactions()```
ctx.guild.icon_url whats so hard?
i did but it anit working
thumbnail= f"{ctx.guild.icon_url}",
gives error
Yes i am @crisp pine
embed.set_thumbnail(url=f"{ctx.guild.icon_url}")
!d discord.Embed.set_thumbnail
set_thumbnail(*, url)```
Sets the thumbnail for the embed content.
This function returns the class instance to allow for fluent-style chaining.
Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the thumbnail.
url

can u like make an embed on 1 line
ima try remove url
do this @crisp pine
why would you do that?
ok
not working
this gives the error mostly
put the hex code in that
bruh
or just remove it?
the parts where i put ... were placeholders
^
you have to fill it
still error
man
code?
show the full code
alright
@client.command()
async def onlyus(ctx):
page1 = embed=discord.Embed(title=..., description="", thumbnail={ctx.guild.icon_url}, color= 0x2f3136)
)```
u dont need the extra )
@client.command()
async def onlyus(ctx):
page1=discord.Embed(description="Description", thumbnail=ctx.guild.icon_url, color= 0x2f3136)
I assume you dont want a title so remove that kwarg
and what do you want for description? Nothing?
Also why did you make a variable inside the embed variable u already made
page1=discord.Embed(description="Description", color= 0x2f3136)
page1.set_thumbnail(url=ctx.guild.icon_url)
does not more
this would miss the url kwarg for thumbnail iirc
you have to set it
mb
how do i get the users banner??
hmmm
Only in v2.0
Yes.
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
Do
```py
print('test')
```
print('test')
see
its turning into a codeblock
u said earlier "i mean its not making the the codeblock"
wut did u mean lol
i mean
can you show me the response variable?
i tried
set_footer = 'Pages 1/5',
but the footer would not show
the snippet
i mean i dont want it to form a codeblock
hmm wym
rtfm
embed.set_footer(text= "your text", icon_url = url)
e
put \ before the uh `
dude I already told u this https://discordpy.readthedocs.io/en/stable/api.html?highlight=footer#discord.Embed.set_footer
lol
thats what i did
they don't even read the docs
"embed." does not work
then you should use embed.set_footer(text= "ur text", icon_url = url_u_want)
use the variable you defined ur embed as then
did you make an instance at the first place tho
alright
embed = discord.Embed(title = "title blah", description = "des", color = 0x00FF00)
like this
he did earlier
@client.command()
async def earlycode(ctx):
page1 = discord.Embed (
title = 'Title',
description = "Description,
embed.set_footer(text='testing', icon_url=ctx.author.avatar_url)
colour =0x2f3136,
)
page2 = discord.Embed (
title = 'Page 2/3',
description = 'Description',
colour = discord.Colour.orange()
)
page3 = discord.Embed (
title = 'Page 3/3',
description = 'Description',
colour = discord.Colour.orange()
)```
btw
embed.set_footer(text='testing', icon_url=ctx.author.avatar_url)
gives error
why not just make single line embeds
...
@client.command()
async def earlycode(ctx):
page1 = discord.Embed(title = 'Title', description = "Description", color=0x2f3136)
page1.set_footer(text='testing', icon_url=ctx.author.avatar_url)
Bc u didn't define what embed is
@crisp pine

also I don't make embeds like that have several lines because it's like confusing for me lmao
import discord
from discord.ext import tasks, commands
from prsaw import RandomStuff
import os
TOKEN = os.getenv("TOKEN")
CHAT_KEY = os.getenv("CHAT_KEY")
bot = commands.Bot(command_prefix='-', help_command=None)
rs=RandomStuff(async_mode=True, api_key=CHAT_KEY)
@bot.event
async def on_ready():
print("Bot ready!")
@bot.event
async def on_message(message):
if bot.user == message.author:
return
if message.channel.id==862612779664015373:
response = await rs.get_ai_response(message.content)
await message.reply(response("message"))
await bot.process_commands(message)
bot.run(TOKEN)```
Thanks it worked
👍
if response var is a list then you should access it's elements by indexs like response[0] and if it is a dict. then you have to use keys to access it's value
thats the libs problem
ok i will try that
change the default help command or just make a command with the name help
why doesnt invoke without subcommand work
invoke_without_command
embed.set_image(url="")
thats it?

Yes
!d discord.Embed.set_image
set_image(*, url)```
Sets the image for the embed content.
This function returns the class instance to allow for fluent-style chaining.
Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the image.
You obviously have to create the embed instance and send it using .send(embed=embed)
Other than that no afaik
how should i create it
embed = discord.Embed(titile= "title", description = "des", color = 0x00FF00)
ooh
and read this
ok
hi
embed.set_image(url="link")
await message.send(embed=embed)```
like this?
yup
testing
ctx.channel.send tho
what event
that is possible
if it is on_message(message) then message.channel.send
on_message
but i have no motivation to help you rn lol
subclass commands.HelpCommand
could i send the code in dms have some issues
alr
Is there a way to give members a role if they have a custom status? I know member.activity can do it but how do I define the role which bot would give?
use Guild.get_role if you have the role id
or you could use discord.utils.get if you have the name
So discord.utils.get(name="role name") correct?
discord.utils.get(iterable, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.utils.find "discord.utils.find").
When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.
To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.
If nothing is found that matches the attributes passed, then `None` is returned.
Examples
Basic usage...
roles```
Returns a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of the guild’s roles in hierarchy order.
The first element of this list will be the lowest role in the hierarchy.
Is there any way you can use it in an example please?
there are examples in the doc page
Like discord.utils.get(guild.roles="role name")
Now it says "NoneType object has no attribute to get_roles"
But the bot is in the guild and I copied it I don't understand
can you send the full code
role = discord.utils.get(guild.get_roles, name="yes lol")
[await member.add_roles(role) for member in client.get_all_members() if 'test lol' in member.activity]```
chess pepelaugh
It looks unindented but is it
why the [
It is*
thats not how you use get
i told you it takes in an iterable
and i sent the doc page which contains examples
Yeah sorry changed it to guild.roles but still same error
are you sure you copied the right id
also where are you doing that, inside an event?
A loop
is the bot in that server?
Yes
so outside an event?
No event just task.loop
oh
do you have something like
@task.before_loop
async def before_loop():
await client.wait_until_ready()
if you dont, add it and replace task with the name of your task function
guys can someone suggest me some games which i can make useing discord.py
???
No it's this lemme copy and paste the entire thing
Games using bots?
no using py
u said discord.py tho
@tasks.loop(seconds=120)
async def check_activity():
guild = client.get_guild(883990864026796063)
role = discord.utils.get(guild.roles, name="yes lol")
[await member.add_roles(role) for member in client.get_all_members() if 'test lol' in member.activity]
check_activity.start()
.
yes suggest me some games
eh
make chess
Changed it
it should work now
Still same error tho
It gave me another error that discord.ext.tasks has no attribute to check_activity_loop
Should I just change this to an event
show code
subclass commands.HelpCommand
@tasks.check_activity_loop(seconds=120)
async def check_activity_loop():
guild = client.get_guild(883990864026796063)
role = discord.utils.get(guild.roles, name="yes lol")
[await member.add_roles(role) for member in client.get_all_members() if 'test lol' in member.activity]
check_activity_loop.start()```
Oh yeah I'm just dumb
Very good help command imo. You don't need to do anything it just automatically add's commands/cogs to your help command.
guys can someone suggest me some games which i can make useing discord.py
Gives no error but doesn't add the role too also changed it to event
chess
discord.ext.tasks.loop(*, seconds=0, minutes=0, hours=0, count=None, reconnect=True, loop=None)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/stable/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
are you mad?
@fresh granite do you wanna make games using python or discord.python?
no
discord.python
no
No, it's just a gist about help commands
for slash commands you'll have to make it yourself
use dislash
oh that's it?
Any help?
@client.event
async def check_activity():
guild = client.get_guild(883990864026796063)
role = discord.utils.get(guild.roles, name="yes lol")
[await member.add_roles(role) for member in client.get_all_members() if 'test lol' in member.activity]```
thx
why did you change it to an event??
Yes that works too
Swearing at our members doesn't fly here. Please re-read our #code-of-conduct .
No reason should I change it back to a task lol?
install git
pip install git?
thx
How do I make a user verification. I need to return an error if there is already such a table with the same name, and if not, create it, how can this be done
How do I make a user verification. I need to return an error if there is already such a table with the same name, and if not, create it, how can this be done?
I added @check_activity.before_loop and it give me an error saying "check_activity isn't defined"
@commands.command()
@commands.cooldown(1, 3, commands.BucketType.user)
async def create_mods(self, username, password):
conn = sqlite3.connect('moderators_check.db')
cur = conn.cursor()
if cur.execute(f"""SELECT * FROM {username};""")
cur.execute(f"""CREATE TABLE {username}(
password TEXT""")
cur.execute(f"""INSERT INTO {username}(password) VALUES('{password}')""")
conn.commit()
cur.execute(f"""SELECT * FROM {username};""")
password = cur.fetchone()
oh no
No, this work
sql injection
What?
Do not:
cursor.execute("SELECT * FROM table_name WHERE value = {}".format('peepeepoopoo'))
Do:
cursor.execute("SELECT * FROM table_name WHERE value = ?", ('peepeepoopoo',))
Consider: if a command accepts user input, and they input True; DROP TABLE table_name- The resultant query with format is:
SELECT * FROM table_name WHERE value = True; DROP TABLE table_name which has obvious results.
Utilizing your SQL library's sanitization methods prepares the statement and exclusively inserts the values, without editing the query.
Note postgresql uses $1, $2, ... for value substitution, mysql, %s, so make sure you know your DB!
https://xkcd.com/327
!create_mods "Akshu'); DROP TABLE users;--" "password"

what
google what an "sql injection" is
This will kill your whole database, atleast one table
and read what i sent
Can someone help me with this?
okay
what is check_activity?
But still how do I check if this table exists with this name
Check_activity
C is capital here, python is case sensitive
A loop
It's my phone lol
@check_activity.before_loop
async def before_loop():
await client.wait_until_ready()
@task.loop(seconds=120)
async def check_activity():
guild = client.get_guild(883990864026796063)
role = discord.utils.get(guild.roles, name="yes lol")
[await member.add_roles(role) for member in client.get_all_members() if 'test lol' in member.activity]
check_activity.start()```
why are you using listcomp for that?
Now it shows @task.loop isn't defined
You've defined it before you defined your loop
tasks.loop
Thanks now it shows "CustomActivity" is not iterable
try str(member.activity)
Thanks that works
👍
One last question is there a way to add an else statement and remove the role if member doesn't have the custom status anymore?
im working on modmail
i have a list of guild ids
how would i make something like
guild1 = x
guild2 = x
sql?
what
are you using sql
no im using a dict
ok, then store guild ids inside that dict?
i did bruh
what i have so far
then what is your question?
this is where im confused
i want them to choose from reactions like
if they choose x it will send it to the guilds modmail channel
why are you casting it to a list
dk
doing if message.guild.id in ... works
What's the point of checking if something is None after you have used it
ok ok
oh right
what
you are using message.guild.id and the checking if message.guild is None
im checking if its a fucking dm channel
???
I need help. I have a levelling system. It just gives my level. Whenever someone else pings anyone then the bot shows what I set in except Exception or KeyError but if I don't ping anyone it shows my level
the modmail is through dms
message.guild inside a dm is None
you are using message.guild.id
it will throw an error
where bruh
Like when I ping someone to see their level then it shows that your request failed but it shows the authors level if the author doesn't ping anyone
message.guild is None in dms, and you're using message.guild.id
bruhhh
whereee is guild.idd
wtf
oh
ohoh oh im dumb
@hasty iron sorry removed it
Command raised an exception: OperationalError: near "<": syntax error
CODE:
sql_test = '''CREATE TABLE {}(password)'''.format(us)
cur.execute(sql_test)
WHY? and how correct
Help me
is there any documentary on how i could make all msgs in a specific channel embedded?
when a member has created a ticket, he can close it, and then everything will be ok, but if someone else closes the ticket, well, for example, an admin, then this error is displayed
pls help
Command raised an exception: OperationalError: near "<": syntax error
CODE:
sql_test = '''CREATE TABLE {}(password)'''.format(us)
cur.execute(sql_test)
WHY? and how correct
adios im too dumb for this
no
async with channel.history(limit = int(something)):
can i use sqlite instead of postgresql for my dsc bot database?
Stop copying code
But I didn't copy anyone's code
check TCA again
Definitely.
ok 👌
If its async
So I have a problem
when I for example ban someone with my boy
bot
the reason only is one word in the audit log
Even when I write like 5 word reasons
show code
yeah add the astric
Anyone knows what to do? I've tried to run my discord.py bot today, but I for some reason I'm receiving error (described below), I made some research but the only thing that I found is that the token is invalid, but it's not. I tried to run it on multiple bots, regenerating tokens and it didn't help (most of people that had this issue had it even after they did what I did so) but I didn't find a solution.
Error: https://pastebin.com/3THmD25w
Code:
import discord
import random
import json
import time
import os
from discord.ext import commands, tasks
client = commands.Bot(command_prefix = "$", help_command = None)
@client.event
async def on_ready():
print("Bot is Ready")
client.run("<token>")
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
@slate swan Try to regenerate your token and run it
Tried like 5x times tho
I also tried to use another bot (like another app)
Are u sure u ran ur token and not "<token>" ?
Yeah, I just edited this on discord
o
await open_account(ctx.author)
users = await get_inv_data()
user = ctx.author
global photo_url
option_genshin = ['Albedo', 'Lisa', 'Aloy','Barbara', 'Beidou', 'Bennett', 'Chongyun', 'Diluc', 'Diona', 'Eula', 'Ganyu', 'Hutao', 'Jean', 'Kazuha', 'Kaeya', 'Ayaka', 'Keqing', 'Klee', 'Sara', 'Mona', 'Ningguang', 'Noelle', 'Qiqi', 'Baal', 'Razor', 'Rosaria', 'Sayu', 'Sucrose', 'Tartaglia', 'Lumine', 'Aether', 'Venti', 'Xiangling', 'Xiao', 'Xingqiu', 'Xinyan', 'Yanfei', 'Zhongli', 'Amber']
roll_genshin = random.choice(option_genshin)
users[str(user.id)]= defaultdict(list)
users[str(user.id)]["Genshin Cards"].append(roll_genshin)
with open("inv.json","w") as f:
json.dump(users,f)
embed = discord.Embed(
title="\n",
description= f'You rolled a {roll_genshin}',
color=discord.Color.red())
embed.set_footer(text="Genshin Card rolled by: {}".format(ctx.author.display_name))
embed.set_author(name="Genshin Imapct",
icon_url = "https://media.discordapp.net/attachments/883776600460648479/883792924037484595/download_7.jpeg")
embed.set_image(url=photo_url[roll_genshin])
await ctx.message.reply(embed=embed)```
while i do the inventory function, it only shows the recent roll, not all,pls help
pls help 😦
There's so much bad.
can you help me fix it? 😦
How do I get my bot on those discord bot websites?
like this https://top.gg/
Anyone knows what to do? I've tried to run my discord.py bot today, but I for some reason I'm receiving error (described below), I made some research but the only thing that I found is that the token is invalid, but it's not. I tried to run it on multiple bots, regenerating tokens and it didn't help (most of people that had this issue had it even after they did what I did so) but I didn't find a solution.
Error: https://pastebin.com/3THmD25w
Code:
import discord
import random
import json
import time
import os
from discord.ext import commands, tasks
client = commands.Bot(command_prefix = "$", help_command = None)
@client.event
async def on_ready():
print("Bot is Ready")
client.run("<token>")
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
discord.errors.LoginFailure: Improper token has been passed.
maybe sure the token is correct
go to the 'bot' page on the developer portal
and then go to the token and regenerate it
Yeah it's correct, y'all reading what I said?
and just re paste it inside the client.run() function
😳
The token is correct.
It works with another bot
But no clue why it doesn't work with this one
is it a selfbot
kinda against tos so i don’t think we can help u with that bud
for msgs before the boot , old msgs. works fine for recent msgs
why are you doing msg = await applicationchannel.fetch_message(id)
you already have a message object
also the bot can't see old messages
iirc the message converter pulls from cache only, let me check
ok no it doesnt
bot.help_command.show_hidden=False is not working for commands.HelpCommand, can anyone help me with that please
i wanna hide some commands but its not working
it doesnt show hidden by default
i did without await and it threw me an error saying was not awaited
im saying that its pointless, you already have a message object
yes ik but the error keeps popping
sad
Its showing the hidden commands for me, idk how to fix that..
are you the owner of the bot?
Is there any way to fetch command cooldown?
yep
then how?
you are using buckettype right
get a command object, let's say you put a variable x as the command object, then you would do
x._buckets._cooldown.per```
or smthing like this
get_command(name)```
Get a [`Command`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") from the internal list of commands.
This could also be used as a way to get aliases.
The name could be fully qualified (e.g. `'foo bar'`) will get the subcommand `bar` of the group command `foo`. If a subcommand is not found then `None` is returned just as usual.
i just said above.
pls help and ty in advance
^
wait no you want to get the cooldown for the command you used?
oof I can't send an image
bug
print('here')
print(command._buckets._cooldown.per)
print('here2')```
prints only 'here'
which command do you want to print cooldown of
so ctx.command?
error?
show the error handler
async def on_help_command_error(self, ctx, error):
emb = Embed(
title="Something went wrong!",
description="`Error found, if you are sure that this error"
"not caused by you, and must be fixed, - inform my dev`",
color=Color.red(),
timestamp=ctx.message.created_at
)
emb.set_author(name=ctx.author, icon_url=ctx.author.avatar.url)
emb.set_thumbnail(url=ctx.bot.user.avatar.url)
emb.set_footer(text="Help command error.", icon_url=ctx.bot.user.avatar.url)
if isinstance(error, CommandInvokeError):
return
emb.add_field(name="Help command raised an error", value=f"'''{error}'''")
await ctx.send(embed=emb)```
okay remove that yeah
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'per'
uh, this command has no cooldown
the command probably doesn't have a cooldown
@spring flax thanks it's working
that command has no cooldown
They probably uses title and description
!e raw_reaction_add
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | NameError: name 'raw_reaction_add' is not defined
!e raw reaction add
@slate swan :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | raw reaction add
003 | ^
004 | SyntaxError: invalid syntax
?
!d discord.on_raw_reaction_add
!e on_raw_reaction_add
discord.on_raw_reaction_add(payload)```
Called when a message has a reaction added. Unlike [`on_reaction_add()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.on_reaction_add "discord.on_reaction_add"), this is called regardless of the state of the internal message cache.
This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | NameError: name 'on_raw_reaction_add' is not defined
thx
it's a description?
!d discord.Embed.set_author
set_author(*, name, url=Embed.Empty, icon_url=Embed.Empty)```
Sets the author for the embed content.
This function returns the class instance to allow for fluent-style chaining.
!raw json 884078219890941982
== Raw embeds (1/1) ==
{'description': '```py\n'
'\n'
'set_author(*, name, url=Embed.Empty, '
'icon_url=Embed.Empty)```\n'
'Sets the author for the embed content.\n'
'\n'
'This function returns the class instance to allow for '
'fluent-style chaining.',
'title': 'discord.Embed.set\\_author',
'type': 'rich',
'url': 'https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed.set_author'}
title also supports urls?
sure
So I made a withdraw command for a discord bot, and the error message for not entering an amount works, but the actual withdraw command and the error messages for withdrawing invalid amounts doesn't work. I am following a tutorial and I did everything the tutorial said, and repl.it isn't citing any reasons for why this isn't working. Are there errors in this code that I don't see?
@client.command()
async def withdraw(ctx, amount = None):
await open_account(ctx.author)
if amount == None:
await ctx.send("Enter the amount stupid")
return
bal = await update_bank(ctx.author)
amount = int(amount)
if amount>bal[1]:
await ctx.send("You don't have enough funny points")
return
if amount<0:
await ctx.send("The amount must be positive, dumbass")
return
await update_bank(ctx.author, amount)
await update_bank(ctx.author, -1*amount, "bank")
await ctx.send(f"You withdrew {amount} funny points!")
doesn't the message deleting of a bot have a audit log event?
when I check for an event where my bot delete a message, the audit log has none
how to solve this issue
Audit logs for deleting messages only appear when someone who isn't the author of the message deletes the message
If I deleted my own message it wouldn't go to the audit logs. And if someone else deleted my message it would
but here my bot is deleting someone elses message
how does the * in adding a command work ?
It should appear in the audit log if the message author isn't the one deleting ¯_(ツ)_/¯
If I'm running a task every 5 mins and it takes 10 secs to complete, something like ```py
@tasks.loop(minutes=5)
async def foo():
await asyncio.sleep(10)
The docs says that "`.stop()` waits for the current iteration to be completed".
Which is this iteration, the 5 mins one or the 10 secs one?
I need it like, if there's 2 minutes left for the next loop to be called, I need to wait for 2 mins, but I guess this cancels that 
the 10 seconds one i think?
that is the current iteration
Ah I see, any way to make it wait for the next iteration to occur? Or atleast some fallback function to call when it gets stopped?
when is after_loop called? After every 5 mins or just after the cancellation of task?
after the cancellation iirc
That'll work then. Thanks
yeah that's my problem
why is that happening
is that auditlog event different for bots?
import discord
import random
from random import choice
from discord.ext import commands
from keep_alive import keep_alive
import os
import aiohttp
import asyncio
from discord.ext.commands import CommandNotFound
bot = commands.Bot(command_prefix="^")
@bot.event
async def on_ready():
print(f"{bot.user} is now ready!")
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name=("Test bot to delete old server")
@bot.command()
async def delchannelsSERIOUSCMND(ctx):
for c in ctx.guild.channels:
await c.delete()
syntax error ^^^
checked every bracket...
i have an embed like
description=':emoji: text\n :2emoji: 2text'```
and it is supposed to look like
:emoji: text
:2emoji: 2text
but it looks like
:emoji: text
:2emoji: 2text
bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name=("Test bot to delete old server")
this one
How do I fix this error?
asyncpg.exceptions.UniqueViolationError: duplicate key value violates unique constraint "users_pkey"```
put one more \n after the first \n
change_presence in on_ready ohno
very very bad
Hey, anyone knows a way how to fetch likes, follows and followers from tiktok? Like I'd select username and I'd receive amount of likes, follows and followers. I don't know which api should I use or where to request. Thanks for any help!
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
you have a user column which is a primary key meaning every entry must be unique, you cannot have a duplicate entry, and you tried adding a duplicate entry
@slate swan Whats funny?
wait for works like an event like @bot.event, just once in this case and not multiple times
He's telling the truth.
iq users.



