#discord-bots
1 messages · Page 589 of 1
It says right above in the page in the link
The discord.py library has now been discontinued by its maintainer.
so?
So some part of the tutorial may not work for version 2.0.0 upwards
you can easily fix that by yourself or by reading the "breaking_changes.md" gist
i dun und why this is not working```py
from discord.ext import commands
import os
import discord
from keep_alive import keep_alive
client = discord.Client()
bot = commands.Bot(command_prefix='rpm' or 'Rpm' or 'RPM')
@bot.command(name="hello")
async def hello_world(ctx: commands.Context):
await ctx.send("Hello, world!")
@bot.command(name="ping")
async def ping(ctx: commands.Context):
await ctx.send(f"Pong! {round(bot.latency * 1000)}ms")
keep_alive()
client.run(os.getenv('TOKEN'))
this is all of them
i dpnt think it works in `client=discord.clien()
- Your only supposed to have one bot variable not two.
- If you want multiple prefixes use a list
two bot variable?
from discord.ext import commands
import os
import discord
from keep_alive import keep_alive
bot = commands.Bot(command_prefix='rpm')
@bot.command(name="hello")
async def hello_world(ctx: commands.Context):
await ctx.send("Hello, world!")
@bot.command(name="ping")
async def ping(ctx: commands.Context):
await ctx.send(f"Pong! {round(bot.latency * 1000)}ms")
keep_alive()
bot.run(os.getenv('TOKEN'))
```like this?
Yes
its still not working anyway
the bot doesnt reply to rpm ping
@client.command(name='help')
async def help(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 client.say(embed = page1)
await client.add_reaction(message, '⏮')
await client.add_reaction(message, '◀')
await client.add_reaction(message, '▶')
await client.add_reaction(message, '⏭')
i = 0
emoji = ''
while True:
if emoji == '⏮':
i = 0
await client.edit_message(message, embed = pages[i])
elif emoji == '◀':
if i > 0:
i -= 1
await client.edit_message(message, embed = pages[i])
elif emoji == '▶':
if i < 2:
i += 1
await client.edit_message(message, embed = pages[i])
elif emoji == '⏭':
i = 2
await client.edit_message(message, embed=pages[i])
res = await client.wait_for_reaction(message = message, timeout = 30.0)
if res == None:
break
if str(res[1]) != '<Bots name goes here>': #Example: 'MyBot#1111'
emoji = str(res[0].emoji)
await client.remove_reaction(message, res[0].emoji, res[1])
await client.clear_reactions(message)```
Ignoring exception in command help:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/Users/aarav/Documents/GitHub/awaffle_bot/main.py", line 129, in help
message = await client.say(embed = page1)
AttributeError: 'Bot' object has no attribute 'say'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/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: AttributeError: 'Bot' object has no attribute 'say'```
its the code for a help command with buttons
and this says say is not a function
then wht do i replace it with
@boreal ravine sorry for the ping but does the import order matter if discord is lower than discord.ext?
Errors?
i typed rpm ping and no reply
why u using old and outdated tutorials
?
not really afaik
Ok thank you
!d discord.TextChannel.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**.
=.=
Was your bot online? Did you do rpmping correctly?
no spacing?
No check your prefix
yeah
its working now
cool
thanks
no problem
oh so i need to make a list of all the pages
you dont but your code makes no sense
🙂
await add_reaction(emoji)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Add a reaction to the message.
The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji").
You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.
so mus the emoji be the code thing or the actual emoji
by code thingy i mean :eyes :
I mean read your own code emoji is always gonna be None
You can get its id or the str version but as kayle stated it will be None
@client.command(name='help')
async def help(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()
done
its working
got it from stack exchange
Not the best way to learn but good for you
nice
In normal code(no cogs) can pop the bots reaction:-
reacted_users.pop(reacted_users.index(bot.user))```
But in cog there is a error:-
```discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.ext.commands.bot' has no attribute 'user'```
Is there a way to pop my bots reaction from the list of reaction in a cog
Is there a way to get deleted images using on_message_delete and send them to a channel, if so how?
print(msg.content)```
This won't send images.
use can send it to a channel too
@client.event
async def on_message_delete(message):
if message.guild:
b = DT.datetime.now().timestamp()
b = int(b)
with open("data.json") as f:
data = json.load(f)
if message.author.id == 503641822141349888:
return
if message.author.bot:
return
if len(message.content) < 1600:
time = datetime.now(tz=pytz.timezone('America/Tijuana'))
formatted = time.strftime("%I:%M %p")
msgtime = (time - message.created_at).total_seconds()
logchannel = client.get_channel(872911089258598421)
am = discord.AllowedMentions(
users=False,
roles=False,
everyone=False,
replied_user=False,
)
await logchannel.send(f'<t:{b}:t> Message by `{message.author}` `({message.author.id})` in {message.channel.mention} has been removed. ({round(msgtime, 2)} seconds after being sent) \n**Content**: {message.content}', allowed_mentions=am)
if len(message.content) > 1600:
time = datetime.now(tz=pytz.timezone('America/Tijuana'))
formatted = time.strftime("%I:%M %p")
msgtime = (time - message.created_at).total_seconds()
logchannel = client.get_channel(872911089258598421)
em = discord.Embed(
description=f'<t:{b}:t> Message by `{message.author}` `({message.author.id})` in {message.channel.mention} has been removed. ({round(msgtime, 2)} seconds after being sent) \n**Content**: {message.content}',
color=0x00a8ff)
await logchannel.send(embed=em)
else:
return``` This is my current, and it doesn't seem to send any images-
u cant send images like that
check if it is a image or a file with .attachment:
!d discord.Message.attachments
A list of attachments given to a message.
@boreal ravine ^^
Bot, not bot when you define it
bot = commands.Bot(command_prefix=prefix, help_command=None)
And since it's in a cog, self.bot
ohk
works thank you
ok so question.....does anybody know a decent line for if someone joins any channel non voice channels for the bot to welcome them?
Like if a user pops into my server I want them to see a greeting page but say they run into a channel like rules or something...is it possible for the bot to greet them on popping into the channel?
Just say how to make "a welcome message".
oh yeah I guess that would be simpler xD
Sorry my brain sometimes overcomplicates things
!d discord.on_member_join you can use that event and get the channel you want the message to be sent to using bot.get_channel(id) and send the message there.
discord.on_member_join(member)``````py
discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
ah thank you!
Also enable the member intents
oh but one more question
I was doing this
@tasks.loop(seconds=10) # '300' is the time interval in seconds.
async def send_message():
"""Sends the message every 300 seconds (5 minutes) in a channel."""
channel = client.get_channel(902885682488422471)
await channel.send('This is a test')
But I get this as an error
Unhandled exception in internal background task 'send_message'.
Traceback (most recent call last):
File "C:\Users\abrod\PycharmProjects\Discord_Bot_Phantom\venv\lib\site-packages\discord\ext\tasks_init_.py", line 101, in _loop
await self.coro(*args, **kwargs)
File "C:\Users\abrod\PycharmProjects\Discord_Bot_Phantom\discord_bot_phantom.py", line 10, in send_message
await channel.send('This is a test')
AttributeError: 'NoneType' object has no attribute 'send'
enable member intents?
you mean the thing on the dev portal?
Channel is none
channel wasnt cached I guess
You probably started the loop before your bot is fully loaded.

!d discord.ext.commands.Bot.wait_until_ready
await wait_until_ready()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits until the client’s internal cache is all ready.
Use that before starting your loop.
Doesnt client.get_channel()need to be awaited too?
no
only coro's need to be awaited
so put await command so it has a moment to wake up?
I see
I guess
And whats a coro?dont know what the term means
Oh im a total idiot lmao....I put it before the on_ready
Oh coro means coroutine🤦♂️
yeah
Yeah, and also enable it in your code
Thx for the link tho
!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.
https://discordpy.readthedocs.io/en/stable/faq.html#how-do-i-send-a-message-to-a-specific-channel hey how come I've never saw this
holy crap more imports xD
Not really justimport Intents and i think its not necessary
^
I still import it tho but its all preference nothing wrong about importing it
Youve never seen that?
from discord.ext import commands, tasks,
This is my import list so far
nope
😭
Ah the potassium monster strikes again xD Sorry...I put that up there I was going to ask if I did that right lmao but brain forgot you are not telepathic...
Or am i?

(>.<) I need money to open a coding dojo.....tell me the winning numbers
1234 
I swear to python jesus if that ends up being anywhere near the winning numbers in my local lottery....for the next month I am buying you ice cream
Appreciate it

Only an ice cream? damn...
how do we use custom emojis with our bot?
Get the id > send it
<:emoji_name:emoji_id>
the bot needs to be in the server to access the servers' emojis
😐 what about gif links
what do you think
a gif ink is a message innit
🤔
sure i guess ¯_(ツ)_/¯
you can add the gif as an emoji to the server and do <a:emojiname:emojiid>
unless if you dont have the perms to add emojis
@client.command()
async def note(ctx, message=None):
await ctx.send('msg.')
msg1 = await client.wait_for("message")
msg2 = msg1.content
msg5 = msg2.lower()
await ctx.send("anothermsg*")
msg = await client.wait_for("message")
msg3 = msg.content
msg4 = msg3.lower()
channel = discord.utils.get(client.get_all_channels(), name=f"{msg5}-{msg4}-notes")
await channel.send(message)
channel_id = channel.id
await ctx.send(f'**CONFIRMATION** The note has been added to \n<#{channel_id}>')
when the message sends to the channel, it is only the first word, why
discord.errors.HTTPException: 429 Too Many Requests (error code: 0): You are being blocked from accessing our API temporarily due to exceeding our rate limits frequently. Please read our docs at https://discord.com/developers/docs/topics/rate-limits to prevent this moving forward. What is this?? and how to solve it
i was using vscode and it worked fine
you are ratelimited
just as i pasted the code in replit and ran i got this error
how to fix it?
i have 2 other bots working fine on replit
because it recieves only a single argument , add * before argument 1
async def note(ctx , * , message.....```
Wait
I think it's every like 5 or 10mins u can request
You can't do anything else
you cant , all you can do is wait
how long?
no idea , i've never been ratelimited
ohk
ty
bruh
it works on vscode
only on replit
@slate swan ^^
just problem with replit
same bot ?
yes
the same token which shows error in replit?
yes
only difference is there is a website in that code to keep the bot alive 24/7
does it have to do anything?
@slate swan
oh
it uses shared ips
wait
so is there a way to host my bot 24/7 for free?
other than replit
like?
https://somehost.xyz is what i use
Free and paid hosting
replit and uptimebot are great starters for a basic discord bot
but very limited
Ye
heroku is also a great service, but it is supposed to be used on websites and there is like limited hours per month
both of them suck if your bot is in over 100 guilds
yeah
of course
i was a former user of both services but as my bot joined more guilds, i just started using a vps
i use this
how many servers your bot is in?
it is paid tho right?
yeah
just created
my bot is in 1 guild 😎
other bots are in like 10
so its fine to start out with replit but remember its just very limited
chad 
i have one in some 72 or idk what guilds
other than that i just make custom bots for servers so 1 guild each
not sure about this hosting service, but does it use like a points service to get hosting?
yeah , it uses point whch you earn while staying on their afk page
what do u mean by limited?
rarely 500mbs of ram and is often laggy
memory
yeah it should be fine then
will switch over when goes over 50
replit takes like 2 minutes to update modules 😌
thats what i call "efficiency"
and poetry often installs wrong modules
^
yeah
i use vultr for hosting but its not free
galaxygate and digitalocean are also good
if looking for a paid one
any idea what's wrong here?
it shows line 46 syntax error
add : to the end
yep
I've got some romanian 4gb ram 2 core vps 20€/year
every if statement ends with a colon
thanks!
thats nice
mine is basically half of that (1 core, 2 gb ram, 2 tb bandwidth for $10)
np!
what is this cringe rate limiting
what do you wanna do?
i wanna add 10 minute mute
when someone uses a banned word
3 times
well whats seems to be the problem
like
i was following an article
so they didnt actually tell
where to put that value
What value
!d discord.Embed.timestamp its a kwarg, add it in the embed instance
The timestamp of the embed content. This is an aware datetime. If a naive datetime is passed, it is converted to an aware datetime with the local timezone.
10 minutes mute
where do you wanna put that
.
import it
Source code: Lib/datetime.py
The datetime module supplies classes for manipulating dates and times.
While date and time arithmetic is supported, the focus of the implementation is on efficient attribute extraction for output formatting and manipulation.
!pypi datetime
wrong one oops
10 minutes?
yes
dont think you can but try google
?
i want it to apply a mute of 10 minutes
any idea how to do that
nope
you want to add a mute role for that?
yes
and
i want it to mute for 10 minutes and only mute some roles
you can use asyncio.sleep to remove the role after adding it
!d asyncio.sleep
coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.
If *result* is provided, it is returned to the caller when the coroutine completes.
`sleep()` always suspends the current task, allowing other tasks to run.
Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.
Deprecated since version 3.8, removed in version 3.10: The `loop` parameter. This function has been implicitly getting the current running loop since 3.7. See [What’s New in 3.10’s Removed section](https://docs.python.org/3/whatsnew/3.10.html#whatsnew310-removed) for more information.
Example of coroutine displaying the current date every second for 5 seconds:
delay must be in seconds so it would be 60*10
hi pls can helpme with discord bot how i can fix it?
The conflict is caused by:
The user requested pynacl==1.2.1
discord-py[voice] 1.2.5 depends on PyNaCl==1.3.0; extra == "voice"
To fix this you could try to:
- loosen the range of package versions you've specified
- remove package versions to allow pip attempt to solve the dependency conflict
!pypi PyNaCl install this
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv i didnt wont mack new user
im working in root
voice is dependent over this lib so it wont work without it
If your only user is root, then you don't need to worry about that warning
The conflict is caused by:
The user requested pynacl==1.2.1
discord-py[voice] 1.2.5 depends on PyNaCl==1.3.0; extra == "voice"
To fix this you could try to:
- loosen the range of package versions you've specified
- remove package versions to allow pip attempt to solve the dependency conflict
🤦♂️
Have you read what it says
Discord.py voice depends on PyNaCl v1.3.0+
You're trying to install version 1.2.1
how install 1.3.0?
Are you using poetry? At least from what I'm seeing the error says
I don't know this is not my bot
How are you installing packages?
No problem, but keep in mind music bot's break ToS
Had I known that's what you were making I wouldn't had helped
im now you mean about youtube?
That as well
Traceback (most recent call last): File "run.py", line 438, in <module> main() File "run.py", line 347, in main finalize_logging() File "run.py", line 179, in finalize_logging dlh.setFormatter(logging.Formatter('.')) File "/usr/lib/python3.8/logging/__init__.py", line 580, in __init__ self._style.validate() File "/usr/lib/python3.8/logging/__init__.py", line 433, in validate raise ValueError("Invalid format '%s' for '%s' style" % (self._fmt, self.default_format[0])) ValueError: Invalid format '.' for '%' style
Music bots breaks ToS on many services
Unless you have bought licenses for every music available you will be breaking a ToS/Copyright
And youtube has a part in their ToS where it says not to bot them
yes i now of ToS
Per rule 5 we can't help you
if youtube didnt close rythm,I would not suffer such bullshit
How come?
Rule 5 in this server has been here way, way before Rythm got shutdown
The rule aply even if that bot exists
Best idea would be to not make music bots :/
or just get a music bot that doesnt use youtube 😎
i won't listen music with friends lol
stop realy lol
best idea is to use spotify
I'll just change the variable to spotify
spotify as in normal spotify
i know
now 😎
You'd still need to buy licenses for every music you play, unless its non-copyrighted
Otherwise that would break copyright laws
yes
if you wont listen with anyone then why make a music bot 
Suggest more topics here!
cooler commands
i dont wont say this
what are cooler commands?
idk
🤩 kick a random person at each command invoked
I made a ban command that if it was invoked by non moderator, it temp banned that user for 1 day
command author was banned*
😂 interesting
indeed, veri useful
normally antispam mutes a person, but I once made it kick them (they receive a invite to rejoin ofc)
But it was only for random testing
The commands become cool😎
why would you want that
don't question that
How do I get the picture of the song and the duration of the song?
in command to play
!ytdl
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)
probably who worked with Genius Api?
I want make command in my bot to get lyrics from track name
my problem: I can`t get lyric,but on local machine all works ok,I need in order to it works on hosting,my code:
def get_lyric(self,track_name):
genius = lyricsgenius.Genius(await self.get_token())
song = genius.search_song(track_name)
return song.lyrics
On hosting I get Error : **403 client error: forbidden for url genius **
yes
how to create command handler
!commandhandler
Hell
I want to create command handlwr
Handler
ok
The error is clear, you're missing the reason parameter, you're probably not invoking the command right
!code your supposed to add an argument
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.

Well for some reason, you cant access the URL
Also don't ping people for help especially moderators.
Whats the error now
That line indicates a command not properly configured
I can't deduce since you didn't paste any code
There are lots of posts on SO that covers this
@slate swan This ones i think could solve you're problem
If you're trying to get a "ban reason", you should use this following syntax when defining the command... ```py
@bot.command()
async def kick(ctx, user: discord.Member, *, reason):
await user.kick(reason=reason)
I don't know if pass_context=True would be required inside the bot.command decorator tho...
It wouldn't
It's useless after v1.0
Anyway... how can i implement custom UI for my discord bot?
UI?
Do you mean like a dashboard or something
Like, those fancy custom widgets, that bots can use to get input from buttons or whatever
Custom Widgets..? You mean buttons?
Like a mini window inside discord chat, that has buttons and/or input fields... for taking user interactions, some uses reactions for this... But sometimes i get to see some bots that render this kind of page on chat...
Something like this
I wonder if it is possible for other type of inputs, like text fields...
Missing indent after line 53 -> else
so like a space line?
ohhh
wtf is a indent
Indents are generally 4 spaces, or tabs ( of 4 spaces )
Bro, stop trolling, indents are like the mantra of python
or 4 spaces before else?
I didnt create this 
I am fucking new to this shit nocap
ok ok sorry
hahah
Learn python first please before you begin this journey
my friend made it and I just want to correct it
valid indentation py if: if_indented else: else_indented not valid ```py
if:
if_indented
else:
else_not_indented
ohhh
okayy wait
hi anyone can turn exe to dmg?
got it, thanks buddy! :)
or uses an autotyper
oh line 56 is also wrong :/
I don't know if you're familiar with other languages such as Java, they use curly brackets {} to wrap the statements, while python don't have them and uses indentations.
okay, I will search it later today
!indent @slate swan
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
I think theres a module for that
could you help with it
!d discord.ui.View for the inputs im not quite sure haven't tested it yet
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
Can't, busy.
When was this feature released?... I come from the 0.16 version...
3-5 months ago in discord.py and a year for discord's API I think
ig
Can someone tell me about
https://discord.readthedocs.io/en/latest/api.html?highlight=create_guild#discord.Client.create_guild
I mean you have all the information right there. It creates a guild.
that’s really all
afaik you can't, rtd though :)
Yes you can
what andy said
Link please
await edit(*, reason=..., name=..., description=..., icon=..., banner=..., splash=..., discovery_splash=..., community=..., region=..., afk_channel=..., owner=..., ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the guild.
You must have the [`manage_guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_guild "discord.Permissions.manage_guild") permission to edit the guild.
Changed in version 1.4: The rules\_channel and public\_updates\_channel keyword-only parameters were added.
Changed in version 2.0: The discovery\_splash and community keyword-only parameters were added.
Changed in version 2.0: The newly updated guild is returned.
why is there a kwarg for that
Because the API allows for it
why not make it another function for that
tysm
Because it makes total sense to have it in edit
Well it doesn't
On the API there is no separate endpoint for transferring
But okay
They all go under PATCH /guilds/guild_id
Uh, yes it does
Like i said earlier, no other endpoint to transfer guild owner
Its all done in PATCH /guilds/guild_id
I see 👀
ah
haven't really used discord's api much except for sending messages 😂
```What does this mean👀?
Exactly what it says
so how is this even useful
To allow guild transfer if the bot made the server
Just completely a shit endpoint
What
You want to get rid of the whole endpoint because a bot in more than 10 servers can't transfer ownership
Well most of the times bots will be in more than 10 guilds
Lmao, brilliant
Yess 10 servers are really less
They should keep it a 1000
If your bot is gonna be that big, it shouldn't be meant to create guilds
The only way for the bot to transfer ownership, is if it was owner in the first place
Your argument makes no sound sense
Well it's a cool feature
Copy a guild then invite the owner then transfer the ownership
That could work, just make the bot leave the server afterwards
So that its always under 10 servers
And what if more thann 11 people invite the bot to their server together
wait for it to get removed from one of the guilds maybe
Looks like most of the time the bot will be busy
Just make a cache for guilds the bot is in and some task to check if the bot is still in there
lol
mhm , thats better
None the less, copying guilds through a bot is completely useless
With the existences of templates you just need a link to it
And the whole guild layout is copied
Well sometimes you don't have permissions to create templates
¯_(ツ)_/¯
And so the bot would need admin to see all the channels, etc
Also while copying the guild its likely to be ratelimited
Due to the channel and role ratelimits
Yup kinda useless bot
And why will someone invite it at the 1st place
They can instead create a template
That's what I'm saying
¯_(ツ)_/¯
Error Anyone Can Fix It?
can anyone send a role_add example?
@slash.slash(
name='giverole',
description='Gives a role to user.',
options=[
create_option(
name='user',
description='Choose the user you want to give role.',
required=True,
option_type=6
),
create_option(
name='role',
description='Choose the role you want to give.',
required=True,
option_type=8
)
]
)
@commands.has_permissions(
manage_roles=True
)
async def giverole(ctx:SlashContext,user:discord.Member,role:discord.Role):
if user.id==ctx.author.id:
embed=discord.Embed(
title='Error!',
description='You can\'t give role to yourself.',
colour=discord.Colour.green()
)
await ctx.send(
embeds=[embed]
)
else:
await user.add_roles(role)
embed=discord.Embed(
title=title_x,
description=f'Succesfully given role to {user.mention}',
colour=discord.Colour.green()
)
await ctx.send(
embeds=[embed]
)
Because there is a space there
i can't ask the member to put the position he wants and his nick... it's basically a captcha system... the bot sends a message to the person's private and he reacts to win the position
space where?
You asked for an example
You want me to send you everything?
role = guild.get_role(id) await member.add_roles(role)
👀
yee, thanks
i will test
!d discord.Member.add_roles
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
bot.add_cog(Some Commands(bot)) This Was There In Line No.13
Where Is The Soace?
Pls Say @valid niche
You can’t be serious right now….
A class name in python must be one single word, with the definition of a word being a piece of text surrounded by white spaces and no white spaces in between
You can ofc have underscored or CamelCase to make it seem like 2 words
In your code right there
There is no real need to go through guilds role cache
There is a space, and a cog name must be a single word
add_roles takes in snowflakes, you just need to create a Object
add_roles(discord.Object(id=...))
Well that’s kinda just more of an exploit/loophole, and you’re skipping some extra verification and cleanness in your code
Its more preformant, and if your using ID its already pretty specific enough to where you 100% know the role exists
add_roles only gets the ID of the role instance to pass it to the payload data, which is why an object would work too, but it just doesn’t look as clean, and if there is an issue where the role is invalid it will catch it much earlier
They catch at the same spot basically
New Error Pls Fix It?
For most these tiny performance things won’t matter, especially in the case of python
@valid niche
No closing quote mark
None has no attr, and then you would raise an error in HTTP for the other
ok
A discord.Object will always work and will never be None
Yes, and I said for that it raises an error in HTTP
@ebon plank okay so let me get this straight with you, how long have you been doing python for?
0
Because it really feels like you never did python before
Okay so you are aware that discord bots are ultimately super complex and really Ill advised for any beginner? It’s bound to trip them up and show errors, and you won’t really learn much from it
The official d.py discord doesn’t support anyone who shows a lack of basic python skills
yes
i am useing repl.it
pls fix that error @valid niche
i trust you
I won’t stop you from doing this project, but after having to tell you how to fix 3 basic errors that you really should’ve known how to fix yourself, I am kind of done with it and I won’t help anymore
If you’re forcing me I definitely won’t
Replit is the worst site to work on code imo. Can’t go lower than that
ok
command invoke error .:(
then which site?
what does this means ```py
, *, text: str
No site. Just a proper editor on your own PC. Like pycharm, vsc, sublime, atom, you name it
Everything that’s after the argument before the star will be consumed into text
Repl.it is the worst site for discord bots
Repl.it is great for on the go env
Fine service, just used for the wrong purpose
It means text is of string type, and will consume any positional argument after the last one
=.=
Am I wrong?
I still hate it for that purpose
Use heroku for hosting and VScode for editing preety simple
It’s just so underpowered and mainly used wrongly which just annoys me a lot
¯_(ツ)_/¯
Heroku is also horrible
What things are you doing on the go that require more power???
It's free
You cannot have 24/7 with heroku unless you pay, and at that point just get a VPS or a RPI
Have two heroku accounts simple
A lot of things, and I just work on my own laptop
¯_(ツ)_/¯
That’s against TOS, and even then you’re still super limited
Why not use heroku or replit
Well IDC bout their ToS
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
Means you won’t get support here either
Have a tasks loop run every minute or so, then have it check the time and if it’s correct send the message
I am not asking for support or breaking any Discord ToS sir
And what basis are you making the claim of their power on?
Is there some sort of benchmark I haven't seen
Or their specs?
You are breaking discord’s ToS. Discord states use of any part of their platform in such a way that breaks the TOS of any other company is also against their TOS. This includes bot hosting and such
-,-
Because it’s a shared public free machine? And the simplest of things, have a for loop count up very fast and you’ll see replit is slower
Use code blocks please
Shared VPS that have 1gb are more than enough for most medium traffic discord bots
Well that’s just an example structure. You will need to code it to your own specs
I asked if there was any benchmark or specs that I could look at as well
How do I insert a bot into an voice channel?
Oh and the massive risk of having your entire account banned because of the shared IP?
await channel.connect()
This also returns a voice client used for sending audio and such
await destination.connect()```
ch : discord.VoiceChannel
await ch.connect()??
That is for hosting discord bots, I'm talking about on the go environments
Well you need to properly define it
How
😐
async def _join(self, ctx: commands.Context):
"""Joins a voice channel."""
destination = ctx.author.voice.channel
if ctx.voice_state.voice:
await ctx.voice_state.voice.move_to(destination)
return
ctx.voice_state.voice = await destination.connect()```
I have this shit code may help you
¯_(ツ)_/¯
You’re just saying variable ch should be of type VoiceChannel. You need to define what voice channel
spoonfeeder!!
All How To make a discord Button
you cant connect to a class
!d discord.ui.View => read examples folder
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
Everything about interactions and Views can be found here: https://discordpy.readthedocs.io/en/master/api.html?highlight=view#bot-ui-kit
@commands.command(name="setstatus")
async def setstatus(self, ctx: commands.Context, *, text: str):
"""Set the bot's status."""
await self.bot.change_presence(activity=discord.Game(name=text))
```why is this not working
Define “not working”
its not showing status on my bot
bot.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name=message))```
Maybe try this
Errors?
@loud junco
That should work
and everone how Change bot status ==> to Watching Example (32342) members
@commands.command(name="setstatus")
async def setstatus(self, ctx: commands.Context, *, text: str):
"""Set the bot's status."""
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name=message))```
alright
hmm
?
await bot.change_presence(
activity=discord.Activity(
type=discord.ActivityType.watching,
name=#Member Count
))```
Discord Bot Cant Diagnosis member count ??
i think can
when did discord.py die??
i just found out about it right now
They can sir
still not working
so wy you Wrtite member count /.
Error please
So you want me to spoonfeed you?
no error but not showing
thats the worst part
XD
idk what am i doing wrong
Sir can you show me your code are you using any error handlers
@commands.command(name="setstatus")
async def setstatus(self, ctx: commands.Context, *, text: str, message):
"""Set the bot's status."""
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name=message))
And BTW you replaced the message with your message right?
the message in name=message?
@commands.command(name="setstatus")
async def setstatus(self, ctx: commands.Context, *, text: str, message):
"""Set the bot's status."""
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name=text))```
Try this
Bruh text is the the message which will be displayed on your bot's activity
Just use the command
Can you tell me your bot's prefix please
rpm
Then use rpmsetstatus Like This!
oo
Worked?
Bro I wanna fucking die
oo
How are you so dumb
;-;
oo
And it will work
You don't need to do anything with the code
Is your bot in this server?
in cogs , its commands.command
oo
Sir how long have you been into discord bots?
i use client = discord.Client() before this
now im changing to bot = commands.Bot()
I totally understand
how i can do this
Do what?
do what
ping a moderator mb
Access the URL?
Idk
....
I don't use heroku
Heroku is dual hosting my bot
wait
IDK why
are u kidding me
.....
bruhhhh
i swear to god
@commands.command(name="setstatus")
async def setstatus(self, ctx: commands.Context, *, text: str, message):
"""Set the bot's status."""
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name=text))
this is in my code
Are you loading the cog
import discord
from discord.ext import commands
import os
from keep_alive import keep_alive
bot = commands.Bot(command_prefix='rpm ')
@bot.event
async def on_ready():
print('We have logged in as {0.user}'.format(bot))
@commands.command(name="setstatus")
async def setstatus(self, ctx: commands.Context, *, text: str, message):
"""Set the bot's status."""
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name=text))
@bot.command(name="hello")
async def hello_world(ctx: commands.Context):
await ctx.send("Hello, world!")
@bot.command(name="ping")
async def ping(ctx: commands.Context):
await ctx.send(f"Pong! {round(bot.latency * 1000)}ms")
keep_alive()
bot.run(os.getenv('TOKEN'))
wowwwwwwww
What an amazing person
😂🤣
Why you ain't using bot.command deco 😐
Bruh
Sir you need to fucking learn
An easy fix is to ditch heroku. Heroku is bad -if not the worst- and most likely never the wtg to host a Discord bot. You've got many choices to host your bot, whether for free or paid.
sherlock tells me heroku is veryyyy good
Tell me some free ones
Heroku is literally dual hosting my bot
I suggest https://somehost.xyz, I work there, and will help you anytime you need. P.s. it's very easy to use, and the uptime is 99.99%.
how can i get it?
tysm sir
self promote 😂 😳
He asked for a free hosting method, so I didn't take the chance for granted. There's nothing bad with supporting a trusted source while you can.
i need import anything?
Im not saying its bad or anything just saying its funny 😂
nope
Yes, your discord library
import discord
from discord import Embed
import asyncio
import os
import string
import random
from discord import Intents
import discord.utils
from discord.utils import get
from asyncio import sleep
from discord.ext import commands, tasks
from discord.ext.commands.errors import CommandInvokeError, CommandNotFound, CommandOnCooldown, MissingRequiredArgument, MissingPermissions
from discord.ext.commands.cooldowns import BucketType
from discord_components import DiscordComponents, Button, ButtonStyle, InteractionEventType
``` i imported all this... was there an error for some wrong library?
class SomeCommands(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
@commands.command(name="setstatus")
async def setstatus(self, ctx: commands.Context, *, text: str, message):
"""Set the bot's status."""
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name=text))
```what is fucking wrong im very mad now
self
you have self.bot but ur not even using it smh 🤦♂️
or use ctx.bot
Calm down with the language, please. And it's self.bot; since it's inside a class. Also, if I may ask, why are you typehinting ctx?
i dont think typehinting it is a bad practise ( in contrast its better )
you can't have more than 1 argument after *, discord.py will consume the rest of the arguments and set it to text, but leaving message alone which raises an error
^ , also the command can make your bot ratelimited if the users try to do something mischievous with it
Why not
typehinting = cool
class SomeCommands(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
def setup(bot: commands.Bot):
bot.add_cog(SomeCommands(bot))
@commands.command(name="setstatus")
async def setstatus(self, ctx: commands.Context, *, text: str):
"""Set the bot's status."""
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name=text))
```bruh
especially in dpy
typehinting makes python look like a programming language
why is ur setup function
inside the cog
ok
You setting it up inside the class?
You may check out this repository if you feel lost. https://github.com/ScopesCodez/discordpy-cogs
Example for using cogs in discord.py. Contribute to ScopesCodez/discordpy-cogs development by creating an account on GitHub.
isnt recommended to load cogs inside on_ready
I know, but I don't have enough time to fix it. So just waiting for a kind person to do it and submit a pull request.
does anyone know how do i run this file
open terminal > python bot.py
Oh yeah and this is not good
client = commands.Bot(...)
Should be
bot = commands.Bot(...)
this is what it says when i type it
open the directory first
cd PathToFile
when on_ready start event_math... how can i do this?
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'edit'
async def edit(inter):
message = await inter.response.send_message("edit")
await asyncio.sleep(3.0)
await message.edit(content="edited")```
thats not how you edit a interaction message
thats disnake so it must be inter.response.edit_response iirc
thanks
has_emote_status = any([a.emoji.is_custom_emoji() for a in user.activities if getattr(a, 'emoji', None)])
if has_emote_status is None:
#do something```
is this formatted properly?
im not sure wether to do py if has_emote_status: #or if has_emote_status != None: #or if has_emote_status == True:
all of them function same
so they will all work?
but the 1st one is most preferable
oh, alright
first one works if the value is not None ( it does not check if its true or not ) , same for second one
the third one makes sure its True
when i do cog.get_all_commands() i get some weird format.. like <discord.ext.commands.core.Command object at .....>
how to fix?
because they are list of objects
because it’s a list of objects
so how do i convert it/
Use list comprehension
you can iterate thru them
How to get the email address of an user
and use .name
Please tell if it's possible or not
you cant
you cant
it would have been really abused if something like that existed :p
imagine..
True I was really shocked when a bot just send me my email
I forgot that I logged on their website
yeah i think oauth2 can do that
Yup it can and I totally forgot that
That column simply just doesn’t exist in that table.
does someone have a vote kick command. so if 4 users vote against a user then the user gets kicked?
like this?
title = cog.qualified_name or "No"
all_cmds = cog.get_commands()
for command in all_cmds:
cmds = command.name
em = discord.Embed(
title=f'{title} Category',
description=f"{cog.description}\n\n`{cmds}`",
color=bot.color
)
await self.send(embed=em)
also cog is an arg..
@sage otter ..
What are you trying to do
Also like I told you. Use list comp.
cmds = [cmd.name for cmd in cog.get_commands()]
its help command using HelpCommand
async def send_cog_help(self, cog)
can u show us how u created the table
Are you even executing and commiting to the db
quick question, this is how u ping a specific user in a msg right? @surreal sierra
I think you can actually
yes, <@id>
okay ty
bot_id INTEGER PRIMARY KEY, count INTEGER
it works.. but it sends multiple embed.. how can I fix that?
Wait you’re using SQLite right?
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'inter'
multiple instances or you sent multiple embeds
something is none
is "int" even a valid data type in sqlite. I’m pretty sure it’s only bigint and integer
multiple instances
Wait a second. Did you try to create a column for the table when the table already existed???
That’s probably why the column didn’t exist because you can’t do that.
Unless you alter the table
Look. It’s not. He’s sending a different embed for every command name.
ah
he iterated it the wrong way then
It exists in the API so maybe yes.
is ti possible to get if a member is in a certain guild but without the bot being into that guild?
send ur line
no…
how to fix?
Already fixed.
@dense swallow
k
Your iterating it wrongly I guess
huh
async def edit(inter):
message = await inter.response.send_message("edit")
await asyncio.sleep(3.0)
await message.inter.response.edit_response(content="edited")``` this?
^
Didn't I already fix this 
"\n".join([i.name for i in cog.get_commands()])
this also gives the cog name next to the command..
Show full command code
async def send_cog_help(self, cog):
title = cog.qualified_name or "No"
em = discord.Embed(
title=f'{title} Category',
description=f"{cog.description}\n\n'`\n`'".join([i.name for i in cog.get_commands()]),
color=bot.color
)
await self.send(embed=em)
hey i was wondering how do you send an embed with ctx
im tryna learn how to make embeds
await ctx.send(embed=embed)
ctx.send(embed=discord.Embed)
thx
Do this
!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.
description = f"{cog.description}\n\n" + "\n".join([i.name for i in cog.get_commands()])
oh
if i place this in my code:
@bot.event
async def on_message(message):
member = message.author
if message.content == 'other':
await member.send('text')
``` the bot don't respond other commands... there are some error?
yes with oauth , that needs user's permission tho
@dense swallow this should do what you want
ok let me try
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host discord.com:443 ssl:default [Connect call failed ('162.159.128.233', 443)]
>>>```
Why TF?
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 510, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed```
thank you! it worked as i wanted it to!!
This is normal on windows
pythonanywhere uses Windows?
According to official d.py. They said it’s just a "asyncio/windows" bad
As well as asyncio and aiohttp internals
How to solve it?
You only get it when you close the bot
@sage otter
You don’t
Fucking kill me
AAAAAAAAAAAA someone please tell me some good places to host bots for free
Please
Heroku doesn't fucking work for me
normal Command doesn't have any attribute regarding filenames
The main problem is they are not free
you can see the Cog name but not the file
I don't want good hosting
mhm.... can anyone help me?
I just want hosting
if ctx.command.cog == bot.get_cog(...):
Cuz it is fucking stuck in the event
^^ @dusk dust
lol
thank you, dude 😉
call get_cog for each cog, not directly pass all of it in the args
if ctx.command.cog not in [bot.get_cog(...), bot.get_cog(...), ...]
which one do u find better aws or google cloud ?
what is the ec2 micro
I will try google for now ig
Is there a limit for bots when it comes to commands/time in general? For instance 8 commands per second is allowed?
why wouldnt it be
I have no idea, I was wondering what exactly is the limit in case my bot is being overloaded with commands. Especially in multiple servers
Mhm, I could try it later but im busy atm
cooldowns
if discord.utils.find(lambda act: isinstance(act, discord.Spotify), member.activities) == True:
listening = "Listening to"
elif discord.utils.find(lambda act: isinstance(act, discord.Spotify), member.activities) == False:
listening = ""
elif discord.utils.find(lambda act: isinstance(act, discord.Spotify), member.activities) == None:
listening = ""``` is this valid?
why do you need a lambda
should i remove it..
Yes but how much should I add for cooldown?
!d lambda
An anonymous inline function consisting of a single expression which is evaluated when the function is called. The syntax to create a lambda function is lambda [parameters]: expression
up to you
!d discord.ext.commands.cooldown
@discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/master/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/master/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").
If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`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") and the local error handler.
A command can only have a single cooldown.
I mean idk try it and see
okay
How do I start I live ongoing timer in python? Coz I'm coding an auction bot.
what am i supposed to do with my bot now that discord.py is dead?
Dead?
O
Thanks!
i've heard about nextcord, pycord, and hikari but i don't know which one to migrate everything to
the best one (in my opinion) is py-cord
how much of my current code would have to change if i migrated it to pycord?
Pls help
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 863, 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: AttributeError: 'NoneType' object has no attribute 'send'
disnake
Something is none
acts = member.activities
act = [i for i in acts if isinstance(i, discord.CustomActivity)]
if act:
act = act[0]
elif discord.utils.find(lambda act: isinstance(act, discord.Spotify), member.activities) == True:
listening = "Listening to Spotify "
act = ""
elif discord.utils.find(lambda act: isinstance(act, discord.Spotify), member.activities) == False:
listening = ""
elif discord.utils.find(lambda act: isinstance(act, discord.Game), member.activities) == True:
playing = "Playing A Game "
act = ""
elif discord.utils.find(lambda act: isinstance(act, discord.Game), member.activities) == False:
playing = ""
elif discord.utils.find(lambda act: isinstance(act, discord.Streaming), member.activities) == True:
streaming = "Streaming on Twitch "
act = ""
elif discord.utils.find(lambda act: isinstance(act, discord.Streaming), member.activities) == False:
streaming = ""
else:
act = 'None'``` where did i go wrong
Something is none
depends, if you install the py-cord 1.7.3 version nothing (even namespaces), indeed if you install the 2.0+ version, you have to change something
Your trying to send something to a channel that doesnt exist or isnt in the cache
run the file?
like 24/7
use a server
im getting the same error with 3.10.0
its says not supported
use another version
use 3.8.10
didnt work
meaning?
isnt self-hosting easier?
its said it supports 3.10.0
you mean using a VPS? Then yes it is.
Better than heroku ngl https://railway.app/
free?
Yes
What are the pros and cons of this
Well they offer hosting
In a better way
than heroku
without downtime
100% uptime
Does it use pyterodactle or whatever it's called?
they earn from thier higher paid plans
its a hosting provider panel
it isnt a hosting service
how can i create a command only IF REQUESTED for logs?
for example !setlogs and the bot asks what channel, after which it does everything, that is it will say which user used that command, user deleted the message etc.
does anyone know how to help me?
This might help you https://www.youtube.com/watch?v=idAKurKoIDA
Welcome to the updated discord.py series - the series where I teach you how to build a discord.py bot for your server! Below are some links to get you started.
Series requirements can be found here:
https://files.carberra.xyz/requirements/discord-bot-2020
You'll also need an IDE; I use Sublime Text in this series:
https://www.sublimetext.com/
...
a db
@coarse shore
Did u use secrets and enviroments?
U need atleast 10% of coding knowledge to use it
how i can use
knowledge