#discord-bots
1 messages · Page 498 of 1
wait so i have no control over those 500 hrs?>
idk bcz i dont use it
anyone else?
im currently trying out dan bot
ohk
yes ik
u have the link? or i can send in dm
i found on google
ok
might be
u dont know
u can control that
oh nice
u hv a bot on danbot?
yeah
k cool
Hello I was testing my bot since morning and suddenly I was termporary blocked by discord for rate limit
When can I try again?
Is it possible to see a duration after which I can run my bot again?
from prsaw import RandomStuff
rs = RandomStuff(async_mode = True)
@bot.event
async def on_message(message):
if bot.user == message.author:
return
if message.channel.id == 888436619328233472:
response = await rs.get_ai_response(message.content)
await message.reply(response)
await bot.process_commands(message)
Why I’m getting error?
strange
the error?
@slate swan check this maybe it helps https://discord.com/developers/docs/topics/rate-limits
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Ignoring exception in command rules:
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 "/home/runner/My-BOT/cogs/rules.py", line 24, in rules
await ctx.send(embed=embed)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/abc.py", line 1065, in send
data = await state.http.send_message(channel.id, content, tts=tts, embed=embed,
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 254, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embed.fields.8.name: This field is required
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1342, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embed.fields.8.name: This field is required
``` Why am I getting this error?
send your code
you are missing name attr in Embed.add_field
Where
hello?
Because you didn't send code
i need help?
Its to big
!paste use this then
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
Just send what's your problem...
add text and send it
read the 2nd line
then get channel: discord.TextChannel and send message in it
there is a prob
like async def send(ctx, channel: discord.TextChannel, *, text)
what?
show your code
@tough wagon y spoonfeed
he didn't?
hey?
embed.set_image(url = ...)
can anyone give me a fully working temp mute source code?
Thank You
that is spoon feeding so no
but tempmute is ez
just make a time converter and then convert the time to the correct one then mute the member and sleep for the exact amount of time
Hey @dim cedar!
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:
then unmute
i made a code
send to my dms
How do I place the picture on top of all the text?
Its currently below everything. I want it before the fields
then go with thumbnails i suppose
hm
other then that no other way
Thumbnails are on the side tho?
this channel is for stuff related to discords api
ohk i wanted some help regarding hosting
Is there a way to have a command handler so I can have separate python files with the commands in? Almost like a sub-cog but i don't have to define each one
dpy has extensions
so im making a server info command, and ive got a few fields right now, and i'll add more later. i decided to test the command, but i get this error:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'tuple' object is not callable
My Code:
@commands.command(aliases = ["si", "guildinfo", "gi"])
async def serverinfo(self, ctx):
embed = discord.Embed(title = "Server Information",
colour = discord.Colour.gold(),
timestamp = ctx.message.created_at)
fields = [("ID", ctx.guild.id, True),
("Owner", ctx.guild.owner, True),
("Region", ctx.guild.region, True),
("Created at", ctx.guild.created_at.strftime("%d/%m/%Y %H:%M:%S"), True),
("Members", len(ctx.guild.members), True,)
("Humans", len(list(filter(lambda m: not m.bot, ctx.guild.members))), True),
("Bots", len(list(filter(lambda m: m.bot, ctx.guild.members))), True),
("Banned Members", len(await ctx.guild.bans()), True),
]
for name, value, inline in fields:
embed.add_field(name = name, value = value, inline = inline)
await ctx.send(embed = embed)
the formatting is a little weird cuz of discord
thanks!
you called a tuple somewhere, if you actually have a traceback it shows which line
this is what you did
in the members line
!e
t = (1,2,3,4)
t()
@valid niche :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | TypeError: 'tuple' object is not callable
that's literally what you did according to the error
Why are u using embeds like that? Just type them normally lol that might fix your problem
i have a lot of fields, so its easier for me to do it this way
@client.event
async def on_guild_channel_join(ctx):
Would it works?
so i mean the trigger
you should firstly loop through the tuples, then unpack the tuples
so 2 times iterating
wdym
on_guild_join or on_voice_state_update works but not that
for field in fields:
for name, value, inline in field:
...
alright i'll try that
actually, your code is right
alright so i tried converting it into an f string, but that still didnt work
which line is the error again?
("Members", f'{len(str(ctx.guild.members))}', True)```


!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.
ctx.voice_client.stop()
AttributeError: 'NoneType' object has no attribute 'stop'
How is this fixable?
I mean , the error says it all , bot is not in a voice channel
the thing is that it is
how is it possible for .voice_client to return None then
guys, should i run a dpy task every 1 second, if no, what should i use since i have to run the thing exactly every 1 second
If it does not make an api call everytime , you can
if the bot joined the voice before it's current session, it will return None also
yeah but should i do it, or does it affect my bots performance?
im uh
not really... depends on what kind of task you're performing
im running a loop to -= 1 a variable in a json file of every users data (which is a dict)
And your memory limits
sure , you can do it
i know this is a bad idea but i dont have any other ideas
of how to decrease 1
in 1 sec
what causes you to decrement a variable for every user data? a timer?
yep, my custom cooldown system
store the user's cooldown time instead of decrementing numbers every second
how would i decrease it?
Try .pause
if this is for a command for example, you can just check during when the user calls a command, and then check if that cooldown time has passed, if it does, allow it
ohhh
that's basically how the normal CooldownMapping work
good idea
but they dont save on restart
thats why im doing this
what's stopping you from just storing that time data lol
since i wont have to store anything if they save
saving is storing, what do you even mean
hey i have problem in this code
but they dont save directly in the bots folder
@bot.event
async def on_raw_reaction_add(payload, ctx):
if payload.member.id != bot.user.id and str(payload.emoji) == u"📥":
msg_id, channel_id, category_id = bot.ticket_configs[payload.guild_id]
if payload.message_id == msg_id:
guild = bot.get_guild(payload.guild_id)
role = guild.get_role(891031599708266629) #replace role_id with your role's id
for category in guild.categories:
if category.id == category_id:
break
channel = guild.get_channel(channel_id)
channel_name = ("ticket-{payload.member.display_name}")
if channel_name in ctx.guild.channels:
print("you have already a ticket open close it first ")
else:
ticket_channel = await category.create_text_channel(f"ticket-{payload.member.display_name}", topic=f"A ticket for {payload.member.display_name}.", permission_synced=True)
await ticket_channel.set_permissions(payload.member, read_messages=True, read_message_history=True, send_messages=True)
await ticket_channel.set_permissions(role, read_messages=False, send_messages=False)
message = await channel.fetch_message(msg_id)
await message.remove_reaction(payload.emoji, payload.member)
await ticket_channel.send(f"{payload.member.mention} Thank you for creating a ticket! Use **'-close'** to close your ticket.")
try:
await bot.wait_for("message", check=lambda m: m.channel == ticket_channel and m.author == payload.member and m.content == "-close", timeout=3600)
except asyncio.TimeoutError:
await ticket_channel.delete()
else:
await ticket_channel.delete()
await coro(*args, **kwargs)
TypeError: on_raw_reaction_add() missing 1 required positional argument: 'ctx'```
any help
but you're saving into a json file every second
ctx, payload?
also I'm pretty sure that isn't the full error
on_raw_reaction_add doesn't get Context, Context are for commands only
hence the error
ok tank for idea
im gonna rework
now i got this erro
Traceback (most recent call last):
File "C:\Users\Mohamed_Zeton\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
TypeError: on_raw_reaction_add() missing 1 required positional argument: 'payload'``` when i tried this one
stella said remove the context arg lol
source = await discord.FFmpegOpusAudio.from_probe(url2, **ffmpeg_options)
discord.errors.ClientException: ffmpeg was not found.
In what sense?
in the sense that you dont have it
right
hi, so I'm starting to use slash commands and ran into a pretty big bump in the road, how can I avoid specifying guilds by their id, can i make it universal for all guilds instead of specifying?
code below:
@slash.slash(
name= "hello",
description= "Just sends a message",
guild_ids = [3453423546354235], # problem
options = [ #ignore this
]
how can i add it?
install it
Requirement already satisfied: ffmpeg in c:\
not pip install
which context arg ?
you mean the ctx ?
yes
yes on_raw_reaction_add event only takes the payload argument
then this one wont work
if channel_name in ctx.guild.channels:```
this line wont work if i remove the ctx
i think its payload.guild_id
i mean you had guild declared there
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS C:\Users\Mohamed_Zeton\Desktop\JOB 1> & C:/Users/Mohamed_Zeton/AppData/Local/Microsoft/WindowsApps/python3.9.exe "c:/Users/Mohamed_Zeton/Desktop/JOB 1/job.py"
CursedMC is ready.
Ignoring exception in on_raw_reaction_add
Traceback (most recent call last):
File "C:\Users\Mohamed_Zeton\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\Mohamed_Zeton\Desktop\JOB 1\job.py", line 40, in on_raw_reaction_add
if channel_name in payload.guild.channels:
AttributeError: 'RawReactionActionEvent' object has no attribute 'guild'```
didnt work
then remove the guild_ids paramater
it checks if the name of the channel in the channels list in the server or no
oh ok
idk maybe check the docs
its guild_id, not guild iirc
what ?
now I get a 403 Forbidden (error code: 50001): Missing Access error
if channel_name in payload.guild_id.channels:
AttributeError: 'int' object has no attribute 'channels'``` now this error
you have guild declared already at the top, just guild.channels
didnt understand
how i can do for example help command and if player add emoji message bot edit
well noemal ppl would get a paginator lib
but some ppl like to code their own paginator
Hey @tiny ibex!
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:
await ctx.guild.category_exists.delete()```
will this work?
Whats the error
hm
I can't understand what's wrong
Hey, so I got a problem with my discord bot. When I do my .join command the bot joins then instantly leaves and joins back in like .1 seconds that will just hear the join and leave sound
@bot.command(pass_context=True, aliases=['j', 'joi'])
async def join(ctx):
channel = ctx.message.author.voice.channel
voice = get(bot.voice_clients, guild=ctx.guild)
if voice and voice.is_connected():
await voice.move_to(channel)
else:
voice = await channel.connect()
await voice.disconnect()
if voice and voice.is_connected():
await voice.move_to(channel)
else:
voice = await channel.connect()
print(f"The bot has connected to {channel}\n")
await ctx.send(f"Joined {channel}")
why are you doing get(bot.voice_clients, guild=ctx.guild)
ctx.guild.voice_client exists
and if you read your code you'll know what happens
thanks anyways
getting this error now
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
anyone ^^
cause this does not work
```py
elif category_exists == True and channel_exists == False:
print("Category exists but channel does not")
await ctx.guild.category_exists.delete()
x = await ctx.guild.create_category('Mailer')
y = await ctx.guild.create_text_channel('mailer-logs',category=x)
embed = discord.Embed(title="Setup",description=f"Bot has been setted up!, use -accessrole[roles]to give staff access to the channel.Check out more information and configurations with -help.",color=0x1793FC)
await ctx.send(embed=embed)
elif category_exists == False and channel_exists == True:```
Guild object has no attribute category_exists
oh
How to delete the message sent by bot after an interval?
Use delete_after kwarg
Is it possible to edit images
Yes, with a library like Pillow
No, I don't, but I almost did xD
U cant right?
is it confirmed
can anyone see what is wrong with my temp mute code?
Not if you don't share code 😉
`time_dict = {"s": 1, "m": 60, "h": 3600, "d": 86400}
invalid_duration_msg = ( "❌ Invalid duration! Here are some examples:\n\n"+ '1tempmute @Big Wumpus 2d Spam- 2 days, with reason "Spam"\n'+ "1 tmute Wumpus 1h- 1 hour without any reason\n"+ "1tempmute Wumpus 20m- 20 minutes without any reason\n"+ "\nYou can also use s for seconds.")
async def time2seconds(send, time):
try:
return int(time[:-1]) * time_dict[time[-1]]
except:
await send(invalid_duration_msg)
return False
@bot.command(aliases=["tmute"])
@commands.guild_only() # So that user can't run the command in DM
@commands.has_permissions(manage_messages=True)
@commands.bot_has_permissions(manage_roles=True)
async def tempmute(ctx , duration: str, *, reason=None,):
unit_tuple = tuple([unit for unit in time_dict.keys()])
sleep_duration = await time2seconds(ctx.send, duration.lower())
if sleep_duration is False:
return
# If duration does not end with one of the units or is not a number, send an error
if not duration.lower().endswith(unit_tuple) or not duration[0].isdigit():
await ctx.send(invalid_duration_msg)
return
muted_role = discord.utils.get(ctx.guild.roles, name="Muted")
await member.add_roles(muted_role, reason=reason)
embed = discord.Embed(
title="✅ Member muted",
color=0xFF6600,
description=f"{member.mention} was temporarily muted by {ctx.author.mention}",
)
embed.add_field(name="Reason", value=reason)
if not duration[-1].isalpha():
embed.add_field(name="Auto-unmute after", value=str(duration) + " seconds")
else:
embed.add_field(name="Auto-unmute after", value=duration)
await ctx.send(embed=embed)
await asyncio.sleep(sleep_duration)
await member.remove_roles(muted_role, reason=reason)`
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
Please use this
i have pasted it there
why is time2seconds async
How to make embed?
copy pasting code and finding errors
nice
!paste or code block
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
@slate swan maybe not here? and !d discord.Embed
thanks
!d. discord.embed
how to make a code block?
!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.
sp what problem do you have?
!d discord.Embed
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
@slate swan STOP
@dim cedar Whats the error
What
doing that command here
there is #bot-commands
copy paste
dont know how to make a temp mute command
nope
still
invalid
well it would be great if someone give me a working temp mute code
@dim cedar first learn python, because you could print or send your duration
second, - your problem is that you are getting @Riad Admin as duration
here (ctx , duration: str, *, reason=None,): you defining duration and reason
no member
oh
i know python
but was lazy to check the code on my own
That's first to do before asking here, second is search in net, last is ask here
too many lines u know
you can do on_guild_join event and check if guild has less member count than you need
yes
await leave()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Leaves the guild.
Note
You cannot leave the guild that you own, you must delete it instead via [`delete()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.delete "discord.Guild.delete").
hm
@boreal ravine he already understood...
how you define in on_guild_join
btw
you can do like async def on_guild_join(some_guild_haha) and if some_guild_haha
there is another thing
what
how can i check multiple ids?
that will always execute, whats the point
if user.id ?
if Guild is always True
i mean only 2 people can use the command
i'll try
check if ctx.author.id in list_of_ids
i meant if some_gild_haha.member_count > some_count: if you want full..
thats not remotely the same or even similar
a list of ids
eh
?
learn python
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
list = [123, 1325123]
i know that
ok then you should be able to do it
i mean is it a variable?
yes XDxD
!e ```py
list = [1, 2, 3]
if 1 in list:
print('1 is in the list')
@hasty iron :white_check_mark: Your eval job has completed with return code 0.
1 is in the list
oh
nvm
i thought you were making a def
??
making a function for ids is weird
making simple things complecated
i made one

but workd for only one id

that means you lack basic knowledge
you were confused on how to make a list of ids
i thought u were making a def called list_of_ids
yep
i named like that on purpose
hmm
so you would know that it is a list of ids
i understand now
hmm my bad
and even if it was a function it wouldnt work
it is just i made a is_owner func once
that i used to check only one id
so i got confused
how do i send files? like images, files, and video?
!d discord.abc.Messageable.send
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**.
zankyou
@knotty lagoon
if the bot leaves then it wont be able to send the message
you have to send -> leave, not leave -> send
oh
!d discord.Guild.system_channel
property system_channel: Optional[discord.channel.TextChannel]```
Returns the guild’s channel used for system messages.
If no channel is set, then this returns `None`.
How to add plain text to embeds?
description ?
Nope outside embed
send('Your text', embed=embed)
if it is not in the embed, it's not part of it, so put seperately
Using the keyword content would be better
why
Cuz, if he don't know about this and use it like send(embed =embed, 'text')
I'm not sure tho if it will cause any error
if you do it like that it will
That's why ^
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: InvalidArgument: file parameter must be File
i put a path to the video
await ctx.send(file="C:\\Users\\ASUS\\Desktop\\Doblox\\bljrcoding.mp4")
file=discord.File("your_path")
oh
async def clear(ctx, amount=5):
if ctx.message.author.id in list:
await ctx.channel.purge(limit=amount)
else:
@commands.has_permissions(administrator)
await ctx.channel.purge(limit=amount)```
what is the prob here?
oh
thn can u tell me
how can me without and the person with admin perm only use this command
Just use the deco at the top
also just use ctx.author.id
ok
ok
@bot.command()
async def embed(ctx):
def check(message):
return message.author == ctx.author and message.channel == ctx.channel
await ctx.send('Waiting for a title')
title = await bot.wait_for('message', timeout=30.0, check=check)
await ctx.send('Waiting for a description')
desc = await bot.wait_for('message', timeout=30.0, check=check)
embed = discord.Embed(title=title.content, description=desc.content, color=0x72d345)
await ctx.channel.purge(limit=5)
await ctx.send(embed=embed)
Got this code from stack overflow
How to send an timeout message?
any1 here knows how to fix this ?
async def updateLoop():
print(f"\n", end='')
print(f"\nStarting update loop...", end='')
await bot.wait_until_ready()
channel = bot.get_channel(STREAMER_CHANNEL)
while(True):
today = datetime.datetime.today()
weekday = today.weekday()
now = datetime.datetime.now()
value = MATRIX[TIMES.index(f"{now.hour}:00")+1][weekday+1]
if (value != "" and value != None):
await channel.purge()
sleep(1)
await channel.send(f"{value} is now live!\nhttps://www.twitch.tv/{value}")
MATRIX[TIMES.index(f"{now.hour}:00")+1][weekday+1] = ""
writeToFile()
await updateImage()
updatestreamerweb()
channel = bot.get_channel(878637135337492502)
await channel.send('@everyone Make sure to check out our awesome website and watch our featured streamers on it to earn points so you can unlock the request feature role on discord by buying it with the points you earn https://www.so-network.blackbullstudio.eu')
else:
print("randomfeature")
future = datetime.datetime(today.year, today.month, today.day, today.hour, 0)
await asyncio.sleep( (future-today).total_seconds() )
this will spam randomfeature
when value is empty
but instead of it spamming randomfeature i want it to execute it only once if the function is called so everytime the function is called it will do it once
yo guys how do I make my bot send pictures, instead of links to images?
await send(file = discord.File("FILENAME.png"))
And how can I sned it to the mentioned channel?
wait so where does the bot get the image?
if you want it to send a web image just change it to
await send("www.your image.png"))
that might work or make a embed for it
Thanks to discord.py, sending local files as embed images is simple. You have to create an instance of discord.File class:
# When you know the file exact path, you can pass it.
file = discord.File("/this/is/path/to/my/file.png", filename="file.png")
# When you have the file-like object, then you can pass this instead path.
with open("/this/is/path/to/my/file.png", "rb") as f:
file = discord.File(f)
When using the file-like object, you have to open it in rb mode. Also, in this case, passing filename to it is not necessary.
Please note that filename can't contain underscores. This is a Discord limitation.
discord.Embed instances have a set_image method which can be used to set an attachment as an image:
embed = discord.Embed()
# Set other fields
embed.set_image(url="attachment://file.png") # Filename here must be exactly same as attachment filename.
After this, you can send an embed with an attachment to Discord:
await channel.send(file=file, embed=embed)
This example uses discord.TextChannel for sending, but any instance of discord.abc.Messageable can be used for sending.
nice
This is not Python...
Use this for discord.py
https://leovoel.github.io/embed-visualizer/
Huh?
just type the embed its not hard at all
Duh
@bot.command()
async def embed(ctx):
def check(message):
return message.author == ctx.author and message.channel == ctx.channel
await ctx.send('Waiting for a title')
title = await bot.wait_for('message', timeout=30.0, check=check)
await ctx.send('Waiting for a description')
try:
except asyncio.TimeoutError
await ctx.channel.purge(limit=5)
await ctx.send('Timeout', delete_after=2)
desc = await bot.wait_for('message', timeout=30.0, check=check)
try:
except asyncio.TimeoutError
await ctx.channel.purge(limit=5)
await ctx.send('Timeout', delete_after=4)
embed = discord.Embed(title=title.content, description=desc.content, color=0x72d345d)
go in #python-discussion
there is nothing in your try block
also you are doing it wrong
!d try except
!d except
hey i am struggling with "InteraktionType" it dosnt work.
i know is is removed or something.
my problem is i don't know was InteraktionType is and also don't know what i have to use instead?
If ctx.author.id in list
To controll the command
?
Anyone?
.join?
fixed
!d discord.ext.commands.check
@discord.ext.commands.check(predicate)```
A decorator that adds a check to the [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or its subclasses. These checks could be accessed via [`Command.checks`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command.checks "discord.ext.commands.Command.checks").
These checks should be predicates that take in a single parameter taking a [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context"). If the check returns a `False`-like value then during invocation a [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure") exception is raised and sent to the [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") event.
If an exception should be thrown in the predicate then it should be a subclass of [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError"). Any exception not subclassed from it will be propagated while those subclassed will be sent to [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error").
!codeblock
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.
class WIP(commands.Cog, name='WIP (SOON)'):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def members(self, ctx):
total = len(ctx.guild.members)
online = len(list(filter(lambda m: str(m.status) == "online", ctx.guild.members)))
idle = len(list(filter(lambda m: str(m.status) == "idle", ctx.guild.members)))
dnd = len(list(filter(lambda m: str(m.status) == "dnd", ctx.guild.members)))
offline = len(list(filter(lambda m: str(m.status) == "offline", ctx.guild.members)))
humans = len(list(filter(lambda m: not m.bot, ctx.guild.members)))
bots = len(list(filter(lambda m: m.bot, ctx.guild.members)))
await ctx.send(f"Total: {total}\nHumans: {humans}\nBots: {bots}\nOnline: {online}\nIdle: {idle}\nDo not Distrub: {dnd}\nOffline: {offline}")```
Output:
Total: 294
Humans: 285
Bots: 9
Online: 1
Idle: 0
Do not Distrub: 0
Offline: 293
"'Nonetype' has no attribute 'send'" on line 50
Only happened after I added the check for admin
ctx.guild.system_channel is None
what
I should explain
It works fine when there is an active system channel and it does exactly what it's supposed to when there is, but when I disabled the system channel it doesnt send the "No system channel" message and gives me an error for a line below it that it shouldnt have even checked (to my knowledge)
If Guild.system_channel is None should move it onto the await ctx.send("no system channel part") and then go down to return and end there, but it doesnt
Guild.system_channel is not the same as ctx.guild.system_channel
Oh
do you know the difference between an instance and a class
Does someone know why It doesnt filter the right stuff
Not really 
I asked what I should know about py before trying to make a discord bot and I wasnt really told anything I didnt grasp but that's probably a poor excuse
How much Python do I need to know?
discord.py is ultimately a complicated Python library for beginners. There are many concepts in there that can trip a beginner up and could be confusing. The design of the library is to be easy to use -- however the target audience for the library is not complete beginners of Python.
With that being said, beginners tend to use this library quite liberally anyway and while I appreciate the endeavour and tenacity it should be noted that asking for help here does take up the valuable time of volunteers. As a result certain knowledge is required before you can actively participate in the help channels:
- The difference between instances and class attributes.
- e.g. guild.name vs discord.Guild.name or any variation of these.
- How to use data structures in the language.
- dict/tuple/list/str/...
- How to solve NameError or SyntaxError exceptions.
- How to read and understand tracebacks.
This list is not exhaustive
How can I fix that?
print(self.bot.user.mention)
print(message.content)
print(message.content.startswith(self.bot.user.mention))```
guys, why does the activity not work?
client = commands.Bot(command_prefix=[".", "ec "], help_command=None, intents=discord.Intents.all(), activity=discord.Watching("Demon Slayer"))
how?
you already have the string for without
yes
so make the one with !
uh okay, i forgot how do it but i think there is info in net...
anyone 🥲
you dont know how to make a string?
i forgot how to insert a symbol into a string
what
cool
!e ```py
string = '@dapper matrix'
print(string)
@hasty iron :white_check_mark: Your eval job has completed with return code 0.
<@!123>
???
OHMYGOD
please halps 🥲
!d discord.Activity
class discord.Activity(**kwargs)```
Represents an activity in Discord.
This could be an activity such as streaming, playing, listening or watching.
For memory optimisation purposes, some activities are offered in slimmed down versions:
• [`Game`](https://discordpy.readthedocs.io/en/master/api.html#discord.Game "discord.Game")
• [`Streaming`](https://discordpy.readthedocs.io/en/master/api.html#discord.Streaming "discord.Streaming")
you should define a separate variable named
activity = discord.Activity(type=discord.AcitivityType.watching(name='SOmething'))
and then do commands.Bot(...., activity=activity)
ohh, lemme try
thats the same
i just edited some stuff
Can anyone help me 😛
activity = discord.AcitivityType.Watching(name='Demon Slayer')
discord has no attribute 'Activity type'
and u just made another variable and did the same thing 😑
i just edited the code
😑 , it still doesnt work
the error?
discord has no attribute 'ActivityType'
presence intents
activity = discord.Activity(type=discord.AcitivityType.watching(name='SOmething'))
you can change watching to playing or listening
!d discord.ActivityType.watching
A “Watching” activity type.
hm
this doesnt work
the different var is probably not needed
i tried already
no way
what
error
and to competing or streaming
👌
umm ok my bad 🥲
i made a typo
i forgot the spellings of activity 😑
Still its not working 😢
error
error
error
just a minute
Name 'spam' is not defined
@shy schooner @boreal ravine
client = commands.Bot(command_prefix=[".", "ec "], help_command=None, intents=discord.Intents.all(), activity=discord.ActivityType.watching(name='Demon Slayer'))
YoU NoObS
@upbeat otter try
yesh
client = commands.Bot(command_prefix=[".", "ec "], help_command=None, intents=discord.Intents.all(), activity=discord.Activity(type=discord.ActivityType.watching, name='Demon Slayer'))```
this
activity = discord activity(discord actitiy listening(name="i"))
wont work
@upbeat otter
Bot got an unexpected keyword argument 'name'
edited
?
i removed it, still the same error
try this lmfao
umm okay sure
this one omfg
I got the systemCheck command to work and now I understand a bit of class vs instance, thank you blanket
nope
no attribute 'listening'
try my pllssssss
ofc yes
dunno if it related or not
okay sure
🤯
wat
bro, it worked 😑 , thanku ❤️
@tough wagon
the intents or the code?
wrong reply 🥲
that was the error their previously not-edited code would have raised
CODE
o nvm
@boreal ravine
worked
#read the fucking manual
😑 my bad, me dumb
me2
Let's be less toxic to people please
xD
rtfm
• Responding with “RTFM”, “just google it” or similar phrases in response to help requests
Means no ^
i thought i didn't say anything toxic, okay..
what
client = commands.Bot
Wdym
!e
myString = 102
myInt = "Hello World!"
print(myString, myInt)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
102 Hello World!
!e
!eval [code]
Can also use: e
*Run Python code and get the results.
This command supports multiple lines of code, including code wrapped inside a formatted code
block. Code can be re-evaluated by editing the original message within 10 seconds and
clicking the reaction that subsequently appears.
We've done our best to make this sandboxed, but do let us know if you manage to find an
issue with it!*
!e [print("Hi!")]
@quaint beacon :white_check_mark: Your eval job has completed with return code 0.
Hi!
#bot-commands
Imagine trying to make an eval command since hours
trying to make?
Eh, I want the bot, ctx and other vars
Just use exec and pass in variables which can be used
!d exec
exec(object[, globals[, locals]])```
This function supports dynamic execution of Python code. *object* must be either a string or a code object. If it is a string, the string is parsed as a suite of Python statements which is then executed (unless a syntax error occurs). [1](https://docs.python.org/3.10/library/functions.html#id2) If it is a code object, it is simply executed. In all cases, the code that’s executed is expected to be valid as file input (see the section “File input” in the Reference Manual). Be aware that the [`nonlocal`](https://docs.python.org/3.10/reference/simple_stmts.html#nonlocal), [`yield`](https://docs.python.org/3.10/reference/simple_stmts.html#yield), and [`return`](https://docs.python.org/3.10/reference/simple_stmts.html#return) statements may not be used outside of function definitions even within the context of code passed to the [`exec()`](https://docs.python.org/3.10/library/functions.html#exec "exec") function. The return value is `None`.
yea that is what I am thinking to do
Haha
how can you do an auto role on a discord bot
like when someone joins a server they automatically receive a role?
yes
you can use on_member_join for that
this isnt workin
i dont get why
can anyone help please?
why is there a syntax spelling error thig
indentation
its not opening cos of that
yh why
ok
deindent that
lol
there was no :
also indent the role line
!resources and check this out because this just hurts
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
yh
it does
how can i fix it
restart your IDE
fixed it
it didnt work
do i have to import something for it?
@client.event
async def on_member_join(member):
role = discord.utils.get(member.guild.roles, name='role name here')
await member.add_roles(role) ```
this should be your code now
@client.event
async def on_member_join(member):
role = discord.utils.get(member.guild.roles, name='role name here')
await member.add_roles(member, role)
this hurts ngl
there has to be member in member.add_roles
didnt work
do you have intents?
show me your error
theres no error it just doesnt work
what does it do
nothing
is the bot online?
it goes on like normal then nothing happens when i join the server
yh
can you show me your whole code?
like the whole thing without the token
delete it rn
you gave us your token
that's a really poor way to get spammed lol
!code use this
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.
token
oh nice
ahh ok
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
wait oof
still not working
rerun the bot? and turn intents on from the dev portal as well
how to turn intents on?
does all of your commands work except that one, or all of them?
https://discord.com/developers/applications , select the app , go in bot
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
and turn them onn
@slate swan
its on the bot tab
yep
also did you give your bot an administrator invite like when inviting it to the server?
YESSS
ok just checking
wait wait wait
FINNALLY THX SOO MUCH ALL THE VIDS ARE OUTDATED
IT LITRALLY TOOK LIKE 3 HOURS
lol xd
@slate swan someone sent this you didnt read it?
everytime gonna me paste this
love the layout
gonna pin it on my cli[board
@slate swan too small
pp?

pp?
yeah...
everyone's gotta realise this at some point
why does this not worko
@bot.command()
async def setcareer(ctx, user:commands.MemberConverter=None, career:str):
if user is None:
user = ctx.author
@slate swan whats the error?
if user == None:
user = ctx.author
i think its that but what error did you get like @boreal ravine said
Hello, can I somehow check an if statement, also if there is no command triggering it?
is there a way to add a subcommand to commands.HelpCommand?
guys, i was following a tutorial, but the client.send_message doesnt work here, what can i replace it with?
async def level_up(users, user, channel):
experience = users[str(user.id)]["experience"]
lvl_start = users[str(user.id)]["level"]
lvl_end = int(experience ** (1/4))
if lvl_start < lvl_end:
await client.send_message(channel, f"{user.mention} has leveled up to {lvl_end}")
users[str(user.id)]["level"] = lvl_end
Don't use a tutorial that is as old as discord self.
yeah, i made my own changes to it, but how do i send a message here?
if channel is defined just channel.send()
i'll check..
import random
import random at the top of your code first
Also no need to put it inside an f string bare variable is okay.
yessir
guys this is my code ```py
@commands.command()
async def mafia(self,ctx,member:discord.Member):
if ctx.message.author.guild_permissions.manage_roles or (self.clanleadera in ctx.message.author.roles) and (self.mafiaa in ctx.message.author.roles):
if (self.euphoriaa in member.roles) or (self.weeda in member.roles) or (self.hallucinationa in member.roles) or (self.aliensa in member.roles) or (self.outlawsa in member.roles) or (self.brotherhooda in member.roles) or (self.dystopiaa in member.roles) or (self.valhallaa in member.roles) or (self.legenda in member.roles) or (self.antibullya in member.roles) (self.untildeatha in member.roles) or (self.fivetha in member.roles) or (self.kalopsiaa in member.roles) or (self.fargoa in member.roles) or (self.phenomenalsa in member.roles) or (self.immortalsa in member.roles) or (self.khokhaa in member.roles) or (self.aesira in member.roles) or (self.djpa in member.roles) or (self.clouda in member.roles) or (self.favelaa in member.roles) or (self.nevadaa in member.roles) or (self.chayatina in member.roles) or (self.bdba in member.roles) or (self.tchintchina in member.roles) :
await ctx.send(embed=self.aembed(ctx.message.author,member))
else:
if (self.mafiaa not in member.roles) :
await member.add_roles(self.mafiaa)
await ctx.send(embed=self.sembed(ctx.message.author,member))
else:
if (self.mafiaa in member.roles) :
await member.remove_roles(self.mafiaa)
await ctx.send(embed=self.fembed(ctx.message.author,member))
get me this error
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 173, in mafia
if (self.euphoriaa in member.roles) or (self.weeda in member.roles) or (self.hallucinationa in member.roles) or (self.aliensa in member.roles) or (self.outlawsa in member.roles) or (self.brotherhooda in member.roles) or (self.dystopiaa in member.roles) or (self.valhallaa in member.roles) or (self.legenda in member.roles) or (self.antibullya in member.roles) (self.untildeatha in member.roles) or (self.fivetha in member.roles) or (self.kalopsiaa in member.roles) or (self.fargoa in member.roles) or (self.phenomenalsa in member.roles) or (self.immortalsa in member.roles) or (self.khokhaa in member.roles) or (self.aesira in member.roles) or (self.djpa in member.roles) or (self.clouda in member.roles) or (self.favelaa in member.roles) or (self.nevadaa in member.roles) or (self.chayatina in member.roles) or (self.bdba in member.roles) or (self.tchintchina in member.roles) :
TypeError: 'bool' object is not callable
The above exception was the direct cause of the following exception:
oh mi good
what the fuck
hahahaha
May I suggest great use of lists and for loops? Hahaha
I don't understand py so I work like this
this error TypeError: 'bool' object is not callable
Is there any solution
!e True()
@cloud dawn :x: Your eval job has completed with return code 1.
001 | <string>:1: SyntaxWarning: 'bool' object is not callable; perhaps you missed a comma?
002 | Traceback (most recent call last):
003 | File "<string>", line 1, in <module>
004 | TypeError: 'bool' object is not callable
That's what's wrong
dude there is no way we’re going to look through every condition to find what caused the error
I would recommend looking through guides like this https://levelup.gitconnected.com/item-for-item-in-list-comprehensions-if-you-want-to-master-it-237e2f7213ee
Big time saver
How does one make a global event handler to provide a message when say I encounter the following message "404 Not Found (error code: 10062): Unknown interaction"?
This still would not fix it since he got like 20 self variables
My suggestion, is to share the whole file so anyone can look for optimizations.
You can have a list of roles and iterate through it and check if the member has that role
at last I have made my eval command, thanks to Bluenix
How do I split bots & members?
use the built in filter function
!d filter
filter(function, iterable)```
Construct an iterator from those elements of *iterable* for which *function* returns true. *iterable* may be either a sequence, a container which supports iteration, or an iterator. If *function* is `None`, the identity function is assumed, that is, all elements of *iterable* that are false are removed.
Note that `filter(function, iterable)` is equivalent to the generator expression `(item for item in iterable if function(item))` if function is not `None` and `(item for item in iterable if item)` if function is `None`.
See [`itertools.filterfalse()`](https://docs.python.org/3.10/library/itertools.html#itertools.filterfalse "itertools.filterfalse") for the complementary function that returns elements of *iterable* for which *function* returns false.
len(list(filter(lambda m: not m.bot, ctx.guild.members))))
len(list(filter(lambda m: m.bot, ctx.guild.members))))
first line is for members
second for bots
Yea that
You could also use sum
Although it could be slower not sure might be the other way around
Hey
rently my account got diabled and i owned a verified discord bot is there a way to send a message in each server to inform them to invite the new bot?
like ?announce (message)
*sends in every server (message)
you need the old bots’ servers
Guys, i am using on_message event to store messages in a txt file, is there a way to ignore the other bot's messages?
Sending messages in every server your bot is esp since its verified will get it banned most likely
ok use the old bot to broadcast the message
iterate through Bot.guilds
and get a channel you want
Do you have some sort of support server or some other platform to make an announcement
yes but its in active and its been botted
well you can probably just edit the old bots’ commands to include an invite to the new bot
Anyone 🥲
by default your bot ignores other bots messages already
its not ignoring
if not you will have to do return if the author's bot attribute is true
that’s only for commands
the library calls process_commands which returns if the author is a bot
yesh
for other bots too
so either way even if it isn't a command it should get ignored
I want to ignore messages by other bots @pliant gulch
Specifies if the user is a bot account.
this should work right?
if message.author is not discord.User.bot:
#do stuff
no
what....
message.author returns either a Member or User which both have the bot attribute
bot is the attribute you access it via dotnotation
it is either True or False
you put that in an if statement
which determines if you return
like this
if discord.User.bot == False:
#do stuff
?
oh
you want the instance of the class
yesh
message.author returns one
oh
when checking if something is false you shouldn't do == rather use is
ah ok
== is checking if the value is the same vs is which checks if it is the same thing
use is for singletons
what is kotoba
ohh
a bot for learning jp, mostly used in japanese learning servers
why would you learn japanese through a discord bot
it's very easy for learning kanji with it
Duolingo 
meh bad for jp (we're switching topic..)
me who barely even knows katakana
bruh
i still cant find how to ignore other bot's messages 😢
hmm? just an if statement
i tried
i mean we told you earlier
i am dumb
we explained
but it's almost the only way
I understood
then how did it not work
Idk 🥲, most prolly cz i am dumb and new for discord py
I'm assuming you got stuck on the instance vs class part
yeah
Have you any knowledge in OOP?
a little
If I put a song in que, my bot won't play it. If I let him leave the voice channel and then I let him rejoin it works, but otherwise not? Can someone help me?
My bot won't play 2 songs in a row
Learn more then
ah okay
discord.py is OOP bssed
I'm sure if you just googled instance vs class it could help explain it as well
why is there a error here
send the code and the error
How can I go about getting all the messages from every channel and public/private thread from my private server into a json file. I want to put the data into pandas and analyze it.
I don't believe discord.py has support for threads so I believe I'll have to rely on the API itself
guys, i figured out how to ignore messages in on_message, but when i use @client.command, it still logs the message of the bot
Help?
there needs to be an _ after YDL
you cant have a space in a variable name
YDL_OPTIONS
im kms
mistakes like these happen to all of us, don't fret :D
it goes on and then off what i do
can i dm you the code and can u help me?
yeah alright but I found the problem
what is it
line 9 - line 39 is indented within the __init__ method
@bot.command()
@has_permissions(delete_messages=True)
async def purge(ctx, messages: discord.messages):
await ctx.channel.purge(limit=1)
await message.delete
how do i make a purge command?
why isnt my script working
@bot.event
async def on_raw_reaction_add(payload):
message_id = payload.message_id
if message_id == 891778706899628032: ## add id msg of the msg you want ppl to react to to get role
guild_id = payload.guild_id
guild = discord.utils.find(lambda g: g.id ==guild_id, bot.guilds)
if payload.emoji.name == 'AU':
role = discord.utils.get(guild.roles, name='AU')
elif payload.emoji.name == 'NA':
role = discord.utils.get(guild.roles, name='NA')
else:
role = discord.utils.get(guild.roles, name=payload.emoji.name)
if role is not None:
member = discord.utils.find(lambda m : m.id == payload.user_id, guild.member)
if member is not None:
await member.add_roles(role)
print("done")
else:
print("memeber not found")```
any one know whats the problem of this code it wont work
this error
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS C:\Users\Mohamed_Zeton\Desktop\JOB 1> & C:/Users/Mohamed_Zeton/AppData/Local/Microsoft/WindowsApps/python3.9.exe "c:/Users/Mohamed_Zeton/Desktop/JOB 1/job.py"
CursedMC is ready.
Ignoring exception in on_raw_reaction_add
Traceback (most recent call last):
File "C:\Users\Mohamed_Zeton\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\Mohamed_Zeton\Desktop\JOB 1\job.py", line 111, in on_raw_reaction_add
member = discord.utils.find(lambda m : m.id == payload.user_id, guild.member)
AttributeError: 'Guild' object has no attribute 'member'```
members not member
it works like this but give me memeber not found
memeber not found
it should work idk why its not working
?
Send the specific code that isn't working and the error
this one work but give me the member not found any help
how to fix it ?
You mean the music?
Wdym
I create a music bot what should i install to use Spotify links?
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
can you help me out here
Are you mod
No
like when i run main it goes on then off
Just reminding you of the rules
Yeah I have no idea
@slate swan line 9
You used client before you defined it
Won't fix your issue but it is an issue that can be fixed
how
How what
To fix it
Move line 9 down
like this?
Yes
You should either get a help channel or ask in #editors-ides to fix your vsc issue
im so confused why isnt it working
Hello, can someone help me?
This is the code:
`@client.command()
async def buildembed(ctx):
def check(message):
return message.author == ctx.author and message.channel == ctx.channel
await ctx.send('Waiting for a title')
title = await client.wait_for('message', check=check)
await ctx.send('Waiting for a description')
desc = await client.wait_for('message', check=check)
await ctx.send('Channel ID')
guild = client.get_guild(12345678)
channel = guild.get_channel(await client.wait_for('message', check=check))
embed = discord.Embed(title=title.content, description=desc.content, color=discord.Color.blue())
await channel.send(embed=embed)`
And this is the error: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'get_channel'
What should i do?
Which line?
channel = guild.get_channel(await client.wait_for('message', check=check))
the 3rd one from bottom to top
The first error means that client.get_guild returned None meaning not cached, wrong id etc
And then channel = guild.get_channel(await client.wait_for('message', check=check)) won't work either
Since it returns a message object not the content of it
you would need to access the content attribute of the message then cast int
Which then gets passed into get_channel
anyone else know how to fix this
okay, i will try
like that? int((await client.wait_for('message', check=check)).content)
yes this would work
But firstly you need to fix the get_guild
as the error suggests its returning None
Either not cached or you gave it the wrong id
how to do it?
Read my above messages
i don't understand
Either the guild isn't cached in the bots guild cache or you gave it the wrong id
Which means when you run get_guild it can't find it thus returns None
this is hard :p
If you're starting without any python knowledge it is
i just wanna make a cool bot :p
To sell?
"Discord Nitro Gen and Checker"
you probably don’t have enough python knowledge for a discord bot
nah, this is old
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
my friend sells it
ok?
dw, i don't sell anything
ok
i need help
as you can see i dont have nitro lol
how do i set member cooldowns for commands on my bot?
Discord Nitro gens are fake
indeed
idk, he have nitro and sells nitros
anyway, can you pls tell me exactly what i need to do pls
that’s besides the point, the point is that you need to learn more python
`@client.command()
async def buildembed(ctx):
def check(message):
return message.author == ctx.author and message.channel == ctx.channel
await ctx.send('Waiting for a title')
title = await client.wait_for('message', check=check)
await ctx.send('Waiting for a description')
desc = await client.wait_for('message', check=check)
await ctx.send('Channel ID')
guild = client.get_guild(12345678)
int((await client.wait_for('message', check=check)).content)
channel_id = await client.wait_for('message', check=check)
channel = guild.get_channel(int(channel_id.content))
embed = discord.Embed(title=title.content, description=desc.content, color=discord.Color.blue())
await channel.send(embed=embed)`
here are resources that can get help you do that
this is what i made
!format
Uh
?
Not what I was looking for
!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.
can someone pls help me?
time.sleep(seconds here)
Nope
for a specific command, where do i put that in the code?
asyncio.sleep(time)
sorry
and you need to import asyncio
show the command

