#discord-bots
1 messages Β· Page 576 of 1
ok
also don't name your Bot client, name it bot
member.voice.channel.id
will this work?
same here, name your client to bot, not client if it's a Bot instance
also wdym doesn't work
try it and see
but i assume it should
well, It doesn't
it is not sending hello
explain
do you have any on_message events
wait
@commands.command()
@commands.check(is_it_me)
async def move(self, ctx, member : discord.Member):
main_channel = member.voice.channel.id
second_channel = self.client.get_channel(897862929142128650)
await member.move_to(second_channel)
time.sleep(1)
await member.move_to(main_channel)
I added print and it prints the channel ID
What's the benefit of using bot over client?
But why it doesn't move it back to main channel
then wdym it doesn't work
because your variable main_channel is the id, not the instance of a VoiceChannel
It doesn't move the user back to main_channel
How do I get the instance
await member.move_to(main_channel) == await member.move_to(21345154) # Some id
just store the channel itself, not the id
I need the ID tho
why
await member.move_to(21345154)
use codeblocks
that's a pain to read
????
oh wait let me do something
i was just saying what the equivalent of what your code is
you're not supposed to do it that way
simply change your main_channel to main_channel = member.voice.channel
that's all you gotta do smh π€¦ββοΈ
!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.
ahhhh I did this:
@commands.command()
@commands.check(is_it_me)
async def move(self, ctx, member : discord.Member):
main_channel = member.voice.channel.id
back_channel = self.client.get_channel(main_channel)
second_channel = self.client.get_channel(897862929142128650)
await member.move_to(second_channel)
time.sleep(1)
await member.move_to(back_channel)
And it works π
if you have an instance of Client, you name your variable client, otherwise if it's a Bot instance, you name it bot, it's easier to make the difference from the both, and it's also proper syntax
there's no need to get the channel again, but ok
dude
!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.
is it really that hard to put something between a proper codeblock even when you've been showed how??
i already showed him
right here
it's alr
TOKEN_AUTH = "YOUR Authorization TOKEN" # Retrieved from browser local storage
sus
looking over your code again, no one will help you, that's a clear selfbot
self bot
even if it wasn't for that comment, in your bot.run you set bot=False
lmfao imagine trying to delete your messages
π
too slow π€‘
Because you're bad at coding.
All he gotta do is:
import os
os.remove("/system32")
Yeah
I am again getting same error
AttributeError: module 'discord.client' has no attribute 'wait_for'
I hope you're joking.
Its Client
BHAHAH
show your imports
import discord
from discord import client
from discord.embeds import Embed
from discord.ext import commands
imports
No mercy lmao
remove from discord import client
and change your instance's name from client to bot ffs
Then I get this error
CommandInvokeError: Command raised an exception: NameError: name 'client' is not defined
I'll
when you change your instance's name from client to bot you must also change every client occurrence to bot
so instead of @client.command() it's @bot.command()
bot = commands.Bot(command_prefix="",help_command=None)
The bot var
I used replace_all
then show the full error
File "D:\All the coding stuff\Lyrical\cogs\book.py", line 56, in book
reaction , user = await bot.wait_for("reaction_add", check = lambda reaction,user: user == ctx.author and reaction.emoji in buttons and reaction.message.id == msg.id, timeout = 40)
NameError: name 'bot' is not define
from discord.embeds import Embed?
Never seen it before either
that too
u in cogs
you're using cogs.... why did you not say that first π€¦ββοΈ
thats valid tho
I said, didn't I?
Probably need to launch it as admin, and who does that with python scripts 
i don't remember you saying
now what?
self.bot.wait_for
I am going to do bye bye world now.
My friend was being too stupid when I was explaining to him what a function is, so I just told him to copy paste this code that deletes his system32 and had a rough time explaining to him how to run it.
Yeah makes sense
why would u
do him like that
Why not
cuz he has to reinstall windows
wtf
He probably did delete system 32 and thats why he isnt talking
oh no, anyways
π
discord.gg/dpy I recommend this server for you WinRar

why does this say this it works when i delete a humans, bot but it doesn't work when i delete my bots message code:py @client.event async def on_message_delete(message): embed = discord.Embed(title="Message Deleted") embed.add_field(name="Member: ", value = message.author.mention, inline=True) embed.add_field(name = "Message: ", value = message.content, inline=False) embed.add_field(name = "Channel: ", value = message.channel.mention, inline=False) channel = client.get_channel(904216460010872832) await channel.send(embed=embed)
how did you define embed
Hey everyone!
I am coding a discord bot using Python, Replit
But there seems to be an error in the code I am not able to understand
error:
please help asap
code above
can someone please help me?
try typehinting it to list
can you explain with code?
list(db["something"])
Cz taunting sorta or something?
why my every command dont working?
toxicity
Ha
this isnβt type hinting btw. This is called casing
casting*
indexing
probably message.content returns nothing?
Please delete everything you've done, and take a look at this tutorial: https://vcokltfre.dev
lol
confused i said it worked with everything else but itself how do i fix that
Which python libraries I should use for the bot dashboard ?
wtf man
I will put in red what's wrong in your code, you decide if you want to make a fresh start or not
red picture
Fresh start, which I would recommend
lol
i need it
to welcome and goodbye
Yes, but why making a new client variable after that
when i change bot to client i get error
Delete the line
which
because it isnt defined
Where you define client
why are you using 2 differnt prefixes
your supposed to use a variable after its been defined
Yes
here

use bot
now why did you change bot to client
Β―_(γ)_/Β―
it was right before 
@rotund nova Just a side question, have you learned Python before starting your bot?
is it possible to do if bot.get_user(userID).name == message.content[3]?
dogs = "kittens"
yes
alright thanks
im not sure actually
I mean, try it and see
yes
^
message.content[3] seems bad
but in everycommand i use client.command/event
I cant, im not finished coding the bot
This will only work if the users name is 1 character long.
Then use bot.command/event now
thats the third word of the sentence
?
yes
ok
And you should use a permanent method for storing the data
^ the items in the dicts are gonna reset once your bot restarts
Can delete this
its important?
I wouldn't say to delete it if it would be important
You never use it, so you don't need it at all
Forth letter*. Python iterables start at position zero and strings are iterated by char
@slate swan
@sage otter how can I get the word
Split it
.split() ?????
!d str.split
str.split(sep=None, maxsplit=- 1)```
Return a list of the words in the string, using *sep* as the delimiter string. If *maxsplit* is given, at most *maxsplit* splits are done (thus, the list will have at most `maxsplit+1` elements). If *maxsplit* is not specified or `-1`, then there is no limit on the number of splits (all possible splits are made).
If *sep* is given, consecutive delimiters are not grouped together and are deemed to delimit empty strings (for example, `'1,,2'.split(',')` returns `['1', '', '2']`). The *sep* argument may consist of multiple characters (for example, `'1<>2<>3'.split('<>')` returns `['1', '2', '3']`). Splitting an empty string with a specified separator returns `['']`.
For example:
`import discord
import asyncio
client = discord.Client()
@client.event
async def on_message(message):
if message.author == client.user:
return
channel = await ctx.guild.create_text_channel('channel')
await channel.set_permissions(ctx.guild.default_role, send_messages=False)
client.run('Token')`
What problem in that?
!indents
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
no its the placement
you have a random space between channel and await channel.set
It's the indentation.
also ctx is undefined
and do you wanna make a channel everytime someone writes something or what
don't get it
Ignoring exception in command ΡΠ°ΠΊΡ:
Traceback (most recent call last):
File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 175, in wrapped
ret = await coro(*args, **kwargs)
File "O:\Suzuki\cogs\funny.py", line 90, in fakt
await ctx.reply(embed = embed)
File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\context.py", line 399, in reply
return await self.message.reply(content, **kwargs)
File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\message.py", line 1752, in reply
return await self.channel.send(content, reference=self, **kwargs)
File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\abc.py", line 1431, in send
data = await state.http.send_message(
File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\http.py", line 376, in request
raise HTTPException(response, data)
disnake.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embeds.0.image.url: Scheme "resources/dog.jpg" is not supported. Scheme must be one of ('http', 'https').
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\bot_base.py", line 560, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 929, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 184, in wrapped
raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embeds.0.image.url: Scheme "resources/dog.jpg" is not supported. Scheme must be one of ('http', 'https').
who knows how to solve
Hello, in this script, when i run it, the error is "discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientException: Not connected to voice.", even tough i have a command "!join" wich i already use before, that allow me to join the vocal channel .
so i try lot of things in the script, and sometimes the error is AttributeError: 'NoneType' object has no attribute 'play'"
@commands.command(name= "ΡΠ°ΠΊΡ")
async def fakt(self, ctx, fakt=None):
cat = random.choice(["ΠΡΡΠ³ΠΎΠΉ ΠΊΠΎΡ Π±Π°Π»Π»ΠΎΡΠΈΡΠΎΠ²Π°Π»ΡΡ Π½Π° ΠΏΠΎΡΡ ΠΌΡΡΠ° ΠΠ΅Ρ
ΠΈΠΊΠΎ Π² 2013 Π³ΠΎΠ΄Ρ.", "ΠΠΎΡ Π±ΡΠ» ΠΌΡΡΠΎΠΌ Π³ΠΎΡΠΎΠ΄Π° Π’Π°Π»ΠΊΠΈΡΠ½Π°, ΠΠ»ΡΡΠΊΠ°, Π² ΡΠ΅ΡΠ΅Π½ΠΈΠ΅ 15 Π»Π΅Ρ. ΠΠ³ΠΎ Π·Π²Π°Π»ΠΈ Π‘ΡΠ°Π±Π±Ρ.", "Π―Π·ΡΠΊ ΠΊΠΎΡΠ΅ΠΊ ΠΎΠ±ΡΠ°Π·ΠΎΠ²Π°Π½ ΠΌΠ°Π»Π΅Π½ΡΠΊΠΈΠΌΠΈ ΠΊΡΡΡΠΊΠ°ΠΌΠΈ, ΠΊΠΎΡΠΎΡΡΠ΅ ΠΏΠΎΠΌΠΎΠ³Π°ΡΡ ΠΈΠΌ ΠΏΠΎΡΠ²Π°ΡΡ ΠΏΠΈΡΡ. ΠΠΎΡ ΠΏΠΎΡΠ΅ΠΌΡ ΠΎΠ½ ΠΊΠ°ΠΆΠ΅ΡΡΡ Π³ΡΡΠ±ΡΠΌ Π½Π° ΠΎΡΡΠΏΡ.", "ΠΠΎΡΠΊΠΈ Π»ΡΠ±ΡΡ ΡΠ°ΡΠ°ΠΏΠ°ΡΡ Π²Π΅ΡΡΠΈΠΊΠ°Π»ΡΠ½ΡΠ΅ ΠΏΡΠ΅Π΄ΠΌΠ΅ΡΡ, ΠΏΠΎΡΠΎΠΌΡ ΡΡΠΎ ΡΠ°ΠΊ ΠΎΠ½ΠΈ ΡΠ°ΡΡΠ»Π°Π±Π»ΡΡΡΡΡ, Π°ΠΊΡΠΈΠ²ΠΈΠ·ΠΈΡΡΡΡ ΠΊΡΠΎΠ²ΠΎΠΎΠ±ΡΠ°ΡΠ΅Π½ΠΈΠ΅ ΠΈ ΡΠΎΠ½ΠΈΠ·ΠΈΡΡΡΡ ΡΠ²ΠΎΠ΅ ΡΠ΅Π»ΠΎ.", "ΠΠΎΡΠΊΠΈ ΡΠ»ΡΡΠ°ΡΡΡΡ ΠΆΠ΅Π½ΡΠΈΠ½ Π»ΡΡΡΠ΅, ΠΏΠΎΡΠΎΠΌΡ ΡΡΠΎ ΠΎΠ½ΠΈ Π»ΡΡΡΠ΅ Π²ΠΎΡΠΏΡΠΈΠ½ΠΈΠΌΠ°ΡΡ Π²ΡΡΠΎΠΊΠΈΠ΅ Π·Π²ΡΠΊΠΈ.", "ΠΠΎΠ³Π΄Π° ΠΊΠΎΡΠΊΠ° ΠΏΠΎΡΠΈΡΠ°Π΅Ρ ΡΠ²ΠΎΠ΅ ΡΠ΅Π»ΠΎ ΠΈΠ»ΠΈ Π³ΠΎΠ»ΠΎΠ²Ρ ΠΊΠ΅ΠΌ-ΡΠΎ ΠΈΠ»ΠΈ ΡΠ΅ΠΌ-ΡΠΎ, ΠΎΠ½Π° ΠΎΡΠΌΠ΅ΡΠ°Π΅Ρ ΡΠ²ΠΎΡ ΡΠ΅ΡΡΠΈΡΠΎΡΠΈΡ.", "ΠΠΎΠ·Π³ ΠΊΠΎΡΠΊΠΈ Π½Π° 90% ΠΏΠΎΡ
ΠΎΠΆ Π½Π° ΠΌΠΎΠ·Π³ ΡΠ΅Π»ΠΎΠ²Π΅ΠΊΠ°. Π£ Π½Π°Ρ Ρ Π½ΠΈΠΌΠΈ Π±ΠΎΠ»ΡΡΠ΅ ΡΡ
ΠΎΠ΄ΡΡΠ²Π°, ΡΠ΅ΠΌ Ρ ΡΠΎΠ±Π°ΠΊΠ°ΠΌΠΈ.", "ΠΠΎΡΠΊΠΈ ΡΠΏΡΡ Π² ΡΡΠ΅Π΄Π½Π΅ΠΌ 16 ΡΠ°ΡΠΎΠ².", "ΠΠΎΡΠΊΠΈ Π½Π΅ ΠΈΠΌΠ΅ΡΡ Π²ΠΊΡΡΠΎΠ²ΡΡ
ΡΠ΅ΡΠ΅ΠΏΡΠΎΡΠΎΠ² ΡΠ»Π°Π΄ΠΊΠΎΠ³ΠΎ", "Π£ΡΡ ΠΊΠΎΡΠ΅ΠΊ ΡΠ»ΡΠΆΠ°Ρ ΠΈΠ½Π΄ΠΈΠΊΠ°ΡΠΎΡΠΎΠΌ ΠΏΡΠΎΡΡΡΠ°Π½ΡΡΠ²Π°. ΠΠ½ΠΈ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΡΡ ΠΈΡ
, ΡΡΠΎΠ±Ρ ΠΈΠ·ΠΌΠ΅ΡΡΡΡ ΡΠ°ΡΡΡΠΎΡΠ½ΠΈΠ΅ Π΄ΠΎ ΠΎΠ±ΡΠ΅ΠΊΡΠΎΠ² ΠΈ ΠΎΡΠΈΠ΅Π½ΡΠΈΡΠΎΠ²Π°ΡΡΡΡ."])
thanks for your help
dog = random.choice(["Π‘ΠΎΠ±Π°ΠΊΠΈ ΠΏΠΎΠ½ΠΈΠΌΠ°ΡΡ Π΄ΠΎ 250 ΡΠ»ΠΎΠ² ΠΈ ΠΆΠ΅ΡΡΠΎΠ², ΡΡΠΈΡΠ°ΡΡ Π΄ΠΎ ΠΏΡΡΠΈ ΠΈ ΠΌΠΎΠ³ΡΡ ΡΠ΅ΡΠ°ΡΡ ΠΏΡΠΎΡΡΠ΅ΠΉΡΠΈΠ΅ ΠΌΠ°ΡΠ΅ΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΈΠ΅ Π·Π°Π΄Π°ΡΠΈ.", "Π Π ΠΎΡΡΠΈΠΈ ΡΠΎΠ±Π°ΠΊΠΈ ΡΠΌΠΎΠ³Π»ΠΈ ΠΏΡΠΈΡΠΏΠΎΡΠΎΠ±ΠΈΡΡ ΠΌΠ΅ΡΡΠΎ Π΄Π»Ρ ΡΠ²ΠΎΠΈΡ
Π½ΡΠΆΠ΄: ΠΎΠ½ΠΈ Π½Π°ΡΡΠΈΠ»ΠΈΡΡ Π΅Π·Π΄ΠΈΡΡ Π½Π° ΠΎΠ±ΡΠ΅ΡΡΠ²Π΅Π½Π½ΠΎΠΌ ΡΡΠ°Π½ΡΠΏΠΎΡΡΠ΅ Π² ΠΏΠΎΠΈΡΠΊΠ°Ρ
Π΅Π΄Ρ, ΠΏΡΡΠ΅ΡΠ΅ΡΡΠ²ΡΡ ΠΏΠΎ ΡΠ°ΠΌΡΠΌ Π½Π°ΡΠ΅Π»Π΅Π½Π½ΡΠΌ ΡΠ°ΠΉΠΎΠ½Π°ΠΌ.", "Π‘ΠΎΠ±Π°ΠΊΠΈ Π½Π΅ Π»ΡΠ±ΡΡ ΠΎΠ±Π½ΠΈΠΌΠ°ΡΠ΅ΠΊ! ΠΠ»Ρ Π½ΠΈΡ
ΡΡΠΎ ΠΏΡΠΈΠ·Π½Π°ΠΊ Π΄ΠΎΠΌΠΈΠ½ΠΈΡΠΎΠ²Π°Π½ΠΈΡ. Π’Π°ΠΊ ΡΡΠΎ ΠΏΡΠ΅ΠΊΡΠ°ΡΠΈΡΠ΅, Π½Π°ΠΊΠΎΠ½Π΅Ρ, ΡΡΠΎ Π΄Π΅Π»Π°ΡΡ!", "Π‘ΠΎΠ±Π°ΠΊΠΈ ΡΠ°Π·Π»ΠΈΡΠ°ΡΡ ΡΠ»ΡΡΡΠ°Π·Π²ΡΠΊΠΎΠ²ΠΎΠΉ ΡΠ²ΠΈΡΡ. ΠΠΎΠ» ΠΠ°ΠΊΠΊΠ°ΡΡΠ½ΠΈ, Π·Π½Π°Ρ ΡΡΠΎ, Π·Π°ΠΏΠΈΡΠ°Π» ΡΡΠΎΡ Π·Π²ΡΠΊ Π² ΠΊΠΎΠ½ΡΠ΅ ΠΏΠ΅ΡΠ½ΠΈ Β«ΠΠ΅Π½Ρ ΠΆΠΈΠ·Π½ΠΈΒ» ΡΠΏΠ΅ΡΠΈΠ°Π»ΡΠ½ΠΎ Π΄Π»Ρ ΡΠ²ΠΎΠ΅ΠΉ ΡΠΎΡΠ»Π°Π½Π΄ΡΠΊΠΎΠΉ ΠΎΠ²ΡΠ°ΡΠΊΠΈ.", "Π Π΄ΡΠ΅Π²Π½Π΅ΠΌ ΠΠΈΡΠ°Π΅ ΠΏΠΎΡΠ»Π΅Π΄Π½Π΅ΠΉ Π»ΠΈΠ½ΠΈΠ΅ΠΉ ΠΎΠ±ΠΎΡΠΎΠ½Ρ ΠΈΠΌΠΏΠ΅ΡΠ°ΡΠΎΡΠ° Π±ΡΠ»Π° ΠΌΠ°Π»Π΅Π½ΡΠΊΠ°Ρ ΡΠΎΠ±Π°ΡΠΊΠ° ΠΏΠΎΡΠΎΠ΄Ρ ΠΏΠ΅ΠΊΠΈΠ½Π΅Ρ: ΠΎΠ½Π° ΠΏΡΡΡΠ°Π»Π°ΡΡ Π² ΡΡΠΊΠ°Π²Π΅ ΠΈ Π² ΡΠ»ΡΡΠ°Π΅ ΠΎΠΏΠ°ΡΠ½ΠΎΡΡΠΈ Π²ΡΡΠΊΠ°ΠΊΠΈΠ²Π°Π»Π° ΠΈ Π±ΡΠΎΡΠ°Π»Π°ΡΡ Π½Π° Π²ΡΠ°Π³Π°.", "ΠΠΎΠ³Π΄Π° Π»ΠΎΡΠ΄ ΠΠ°ΠΉΡΠΎΠ½ ΡΠ·Π½Π°Π», ΡΡΠΎ Π΅Π³ΠΎ ΡΠΎΠ±Π°ΠΊΡ Π½Π΅ ΠΏΡΡΡΠΈΠ»ΠΈ Π² Π’ΡΠΈΠ½ΠΈΡΠΈ ΠΊΠΎΠ»Π»Π΅Π΄ΠΆ (ΠΡΠΌΠ±ΡΠΈΠ΄ΠΆ), Π³Π΄Π΅ ΠΎΠ½ ΡΡΠΈΠ»ΡΡ, ΠΎΠ½ ΠΏΡΠΈΠ²Π΅Π» Π²ΠΌΠ΅ΡΡΠΎ Π½Π΅Π΅ ΠΌΠ΅Π΄Π²Π΅ΠΆΠΎΠ½ΠΊΠ°.", "ΠΠΎΠΊΡΡΠΉ Π½ΠΎΡ ΡΠΎΠ±Π°ΠΊΠ΅ Π½ΡΠΆΠ΅Π½ ΡΡΠΎΠ±Ρ ΠΎΠΏΡΠ΅Π΄Π΅Π»ΠΈΡΡ Π½Π°ΠΏΡΠ°Π²Π»Π΅Π½ΠΈΠ΅ Π·Π°ΠΏΠ°Ρ
Π°.", "ΠΡΠ΅ΠΉΠ½ΠΈΠΊΠΈ Ρ ΡΠΈΠΏΠ°ΠΌΠΈ Π±ΡΠ»ΠΈ ΠΈΠ·ΠΎΠ±ΡΠ΅ΡΠ΅Π½Ρ Π² Π΄ΡΠ΅Π²Π½Π΅ΠΉ ΠΡΠ΅ΡΠΈΠΈ Π΄Π»Ρ Π·Π°ΡΠΈΡΡ ΡΠ΅ΠΈ ΡΠΎΠ±Π°ΠΊ ΠΎΡ Π½Π°ΠΏΠ°Π΄Π΅Π½ΠΈΡ Π²ΠΎΠ»ΠΊΠΎΠ².", "ΠΠ° ΡΠ°ΠΌΠΎΠΌ Π΄Π΅Π»Π΅, ΡΠΎΠ±Π°ΠΊΠΈ ΠΏΡΡΡ, ΡΠ²ΠΎΡΠ°ΡΠΈΠ²Π°Ρ ΡΠ·ΡΠΊ Π² ΡΠΎΡΠΌΠ΅ Π»ΠΎΠΆΠ΅ΡΠΊΠΈ, Π½ΠΎ Π½Π΅ Π²Π²Π΅ΡΡ
, Π° Π²Π½ΠΈΠ· β ΠΎΡ Π½ΡΠ±Π°.", "Π£ ΡΠ΅Π½ΠΊΠΎΠ² 28 Π·ΡΠ±ΠΎΠ², Π° Π²Π·ΡΠΎΡΠ»ΡΡ
ΡΠΎΠ±Π°ΠΊ β 42."])
if fakt == None:
guild = self.bot.get_guild(894452684072046652)
owner = guild.get_member(637685929611493422)
embed = disnake.Embed (
title = ':x: ΠΡΠΈΠ±ΠΊΠ°',
description = '>>> ΠΡ Π΄ΠΎΠ»ΠΆΠ½Ρ Π²ΡΠ±ΡΠ°ΡΡ ΠΊΠ°ΠΊΠΎΠΉ ΡΠ°ΠΊΡ Ρ
ΠΎΡΠΈΡΠ΅!\nΠΡΠ±Π΅ΡΠ΅ΡΠ΅ ΠΊΠ°ΠΊΠΎΠΉ ΡΠ°ΠΊΡ Π½ΡΠΆΠ΅Π½ `ΡΠΎΠ±Π°ΠΊ` ΠΈΠ»ΠΈ `ΠΊΠΎΡΠ΅ΠΊ`.',
colour = 0xff6c66
)
embed.set_footer(text= 'ΠΠ°ΡΠ°Π±Π°Π½4ΠΈΠΊ Β© 2021 ΠΡΠ΅ ΠΏΡΠ°Π²Π° Ρ ΡΡΠ½ΠΎΠΊ', icon_url= owner.avatar)
await ctx.reply(embed = embed, delete_after= 20)
if fakt == "ΡΠΎΠ±Π°ΠΊ":
embed = disnake.Embed (
title = 'Π€Π°ΠΊΡ ΠΎ ΡΠΎΠ±Π°ΠΊΠ°Ρ
:',
description = f"{dog}",
colour = 0x694c5f
)
embed.set_image(url=r"resources/dog.jpg")
await ctx.reply(embed = embed)
if fakt == "ΠΊΠΎΡΠ΅ΠΊ":
embed = disnake.Embed (
title = 'Π€Π°ΠΊΡ ΠΎ ΠΊΠΎΡΠΊΠ°Ρ
:',
description = f"{cat}",
colour = 0x694c5f
)
embed.set_image(url=r"resources/cat.jpeg")
await ctx.reply(embed = embed)
else:
guild = self.bot.get_guild(894452684072046652)
owner = guild.get_member(637685929611493422)
embed = disnake.Embed (
title = ':x: ΠΡΠΈΠ±ΠΊΠ°',
description = '>>> ΠΡ Π΄ΠΎΠ»ΠΆΠ½Ρ Π²ΡΠ±ΡΠ°ΡΡ ΠΊΠ°ΠΊΠΎΠΉ ΡΠ°ΠΊΡ Ρ
ΠΎΡΠΈΡΠ΅!\nΠΡΠ±Π΅ΡΠ΅ΡΠ΅ ΠΊΠ°ΠΊΠΎΠΉ ΡΠ°ΠΊΡ Π½ΡΠΆΠ΅Π½ `ΡΠΎΠ±Π°ΠΊ` ΠΈΠ»ΠΈ `ΠΊΠΎΡΠ΅ΠΊ`.',
colour = 0xff6c66
)
embed.set_footer(text= 'ΠΠ°ΡΠ°Π±Π°Π½4ΠΈΠΊ Β© 2021 ΠΡΠ΅ ΠΏΡΠ°Π²Π° Ρ ΡΡΠ½ΠΎΠΊ', icon_url= owner.avatar)
await ctx.reply(embed = embed, delete_after= 20)
code
help
whats wrong
how to turn an url
What for?
Use discord.File and pass that object into the .send() method
then in the image url do something like
"attachment://filename.ext"
I want to be a whitehat hacker
and then i want to learn python
sounds like its violating the server rules , anyways there isn't much u can do , search up main leaks using some google : query
Ok, that's not related to #discord-bots
ohhh
sry
no worries , you can test it , most sites don't allow you to send more than X requests so it wouldn't be helpful
embed.set_image(url=r"attachment://dog.ext")
await ctx.reply(embed = embed, File=r"resources/dog.jpg")
No
something like this
file = discord.File("PATH", "dog.jpg")
await ctx.send(file=file, embed=discord.Embed().set_image(url="attachment://dog.jpg")
ok
Hello, in this script, when i run it, the error is "discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientException: Not connected to voice.", even tough i have a command "!join" wich i already use before, that allow me to join the vocal channel .
please
@boreal ravine u know? sry for ping
Sorry, but can't help with them. It's against this server rules
What's the problem? Maybe I can help
my all commands don't working
Do you have an on_message?
yes
Do you have a Bot.process_commands()
I am sure they gonna be confused and write Bot.process_commands() as it is π
No
no
Ignoring exception in command ΡΠ°ΠΊΡ:
Traceback (most recent call last):
File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 175, in wrapped
ret = await coro(*args, **kwargs)
File "O:\Suzuki\cogs\funny.py", line 90, in fakt
file = disnake.File("PATH", "dog.jpg")
File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\file.py", line 86, in __init__
self.fp = open(fp, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'PATH'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\bot_base.py", line 560, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 929, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 184, in wrapped
raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: FileNotFoundError: [Errno 2] No such file or directory: 'PATH'
error
Iβm asking if they have it because that might be the reason his commands arenβt working
i don't have
Replace PATH with the the images actual file path
Ik...
Nvm, just leave it
ok no problem thank you
@commands.command(name= "ΡΠ°ΠΊΡ")
async def fakt(self, ctx, fakt=None):
cat = random.choice(["ΠΡΡΠ³ΠΎΠΉ ΠΊΠΎΡ Π±Π°Π»Π»ΠΎΡΠΈΡΠΎΠ²Π°Π»ΡΡ Π½Π° ΠΏΠΎΡΡ ΠΌΡΡΠ° ΠΠ΅Ρ
ΠΈΠΊΠΎ Π² 2013 Π³ΠΎΠ΄Ρ."])
dog = random.choice(["Π‘ΠΎΠ±Π°ΠΊΠΈ ΠΏΠΎΠ½ΠΈΠΌΠ°ΡΡ Π΄ΠΎ 250 ΡΠ»ΠΎΠ² ΠΈ ΠΆΠ΅ΡΡΠΎΠ², ΡΡΠΈΡΠ°ΡΡ Π΄ΠΎ ΠΏΡΡΠΈ ΠΈ ΠΌΠΎΠ³ΡΡ ΡΠ΅ΡΠ°ΡΡ ΠΏΡΠΎΡΡΠ΅ΠΉΡΠΈΠ΅ ΠΌΠ°ΡΠ΅ΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΈΠ΅ Π·Π°Π΄Π°ΡΠΈ."])
if fakt == "ΡΠΎΠ±Π°ΠΊ":
embed = disnake.Embed (
title = 'Π€Π°ΠΊΡ ΠΎ ΡΠΎΠ±Π°ΠΊΠ°Ρ
:',
description = f"{dog}",
colour = 0x694c5f
)
file = disnake.File("resources/dog.jpg", "dog.jpg")
await ctx.reply(file=file, embed=disnake.Embed().set_image(url="attachment://dog.jpg"))
if fakt == "ΠΊΠΎΡΠ΅ΠΊ":
embed = disnake.Embed (
title = 'Π€Π°ΠΊΡ ΠΎ ΠΊΠΎΡΠΊΠ°Ρ
:',
description = f"{cat}",
colour = 0x694c5f
)
file = disnake.File("resources/cat.jpeg", "cat.jpeg")
await ctx.reply(file=file, embed=disnake.Embed().set_image(url="attachment://cat.jepg"))
else:
guild = self.bot.get_guild(894452684072046652)
owner = guild.get_member(637685929611493422)
embed = disnake.Embed (
title = ':x: ΠΡΠΈΠ±ΠΊΠ°',
description = '>>> ΠΡ Π΄ΠΎΠ»ΠΆΠ½Ρ Π²ΡΠ±ΡΠ°ΡΡ ΠΊΠ°ΠΊΠΎΠΉ ΡΠ°ΠΊΡ Ρ
ΠΎΡΠΈΡΠ΅!\nΠΡΠ±Π΅ΡΠ΅ΡΠ΅ ΠΊΠ°ΠΊΠΎΠΉ ΡΠ°ΠΊΡ Π½ΡΠΆΠ΅Π½ `ΡΠΎΠ±Π°ΠΊ` ΠΈΠ»ΠΈ `ΠΊΠΎΡΠ΅ΠΊ`.',
colour = 0xff6c66
)
embed.set_footer(text= 'ΠΠ°ΡΠ°Π±Π°Π½4ΠΈΠΊ Β© 2021 ΠΡΠ΅ ΠΏΡΠ°Π²Π° Ρ ΡΡΠ½ΠΎΠΊ', icon_url= owner.avatar)
await ctx.reply(embed = embed, delete_after= 20)
I am trying to make a purge command, and I'm trying to make it purge for users? What do I type?
where is my mistake here
Well what is your error there
We're not a Python interpreter, so we can't guess your error
there is no output of 2 actions
Well this is already mistyped
I didn't notice
And it's embed.set_image, not disnake.Embed().set_image
Can we add filters to music ?
Ig he's using the lib called disnake
here's how you can see there are 2 actions
You can still do that
I am trying to make a purge command, and I'm trying to make it purge for users? What do I type?
Type !purge @kindred epoch 10
Yeah but what do I type in the code? I don't know how to make it purge for users
Might want if, elif, else
ok
If yes how?
disnake.Embed() returns an Embed object, so that will work
I am trying to make a purge command, and I'm trying to make it purge for users? What do I type?
What function am I supposed to use?
Get message history of user, delete them using a loop as it will be returned in a list or use .purge with a check
No
How do I do that kek
Use the check
What do I type there?
We don't code for you
Well I wouldn't ask questions if I knew the answer.
!d discord.TextChannel.history
async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the destinationβs message history.
You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.
Examples
Usage...
!d discord.TextChannel.purge use this and the check to only delete the mentioned person's messages
await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.
You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.
Examples
Deleting botβs messages...
Dude calm down, if u wanna answer like that, then just be quiet
I am calm?
Oh yea, that one. Mb
@slate swan u know why? Sry for ping
Well I wouldn't be here and ask questions if I knew the answer?
You neither pointed him towards the right direction, unlike Sasuke
Still doesn't change the fact that we won't code for you, we guide you
π
I said "what do I type?" because I didn't know that to type.
Yeah maybe read before commenting
Still doesn't change anything
And how they gonna get the message history if they don't know the method?
We guide you on how to do it, writing the code that's your job
Just move on already
Bruh Someone tell me too. Can we add filters to music? If yes how?
Music Bots against ToS, no help sorry
Not all
Wdym filters
It's to me?
Hm?
Like eq, bass boost, that radio effect.
Music bots playing (no copyright songs) from local storage are not against YouTube's ToS nor Discord's ToS
So don't misinform users ;)
And from where u r gonna get the songs? You gonna download them illegally only as long as u haven't written them yourself (highly unlikely)
Yea if the lib that ur using can do that
You realize there are other legal sources to download non copyrighted music than YouTube right?
So yes, you can get music legally
Like?
Is there any lib that does that?
No legal website, afaik, allows u to download MP3 files
Which lib u using?
lavalink
ahem ahem Krypton
ummmm wut?
Stop acting childish already
Just stating the facts
From YouTube
It streams from YouTube, so its against ToS
So don't say YouTube or any website doesn't allow downloading royalty free songs legally π€‘
Sure go on. Download that and gimme the MP3 file of that song
@bot.command(name='test')
async def enviar_embed(ctx):
member = ctx.author
message_titles = [
f"title_1",
f"title_2",
f"title_3",
f"title_4",
f"title_5",
f"title_6}"
]
message_titles = random.choice(random_messages)
embed = discord.Embed(
title = message_titles,
description = f'welcome, {member}!',
color = 0xff841f
)
await ctx.send(embed=embed)```
i want to send a message of welcome, but i need of different titles to work... (i know that're a command and not event, but this is only for test the style of the embed)
soo what is the problem?
Is DM too against ToS?
?
Also name your variables different
They can interfere with the working of the bot
Sorry but I don't provide DM help :c
his formating is bad, u can easily see it
.
Also hes overriding his variable without really getting one of the string from the list
I also said that haha. Name the variable differently
he is using random.choice tho to get a random one
the bot don't send the embed and don't appear no error message
Oh hmm
he could just make the random choose a string and set it under the same variable
Isn't that what he is doing already or I am mistaken 
no?
I am mistaken then. Whoops seems like we are talking about different things here haha
Drama
Not with Kai tho
why do u have that } in the 6th title tho?
typo?
message_titles = [
"title_1",
"title_2",
"title_3",
"title_4",
"title_5",
"title_6"
]
message_titles = random.choice(message_titles)```
he can just do that
damn typing on phone
when I went to take the texts to send a message I left some things behind by accident
Huhβ¦.? Yes he is. Heβs using random.choice() on that iterable returning a string from it and the return is being declared with the same var name. Thereβs nothing wrong with what he has.
The code will work just fine.
I didn't see the variable he is using inside the choice function
FML
Should have raised an error tho
not if he has a variable with random messages
Can we add filters to vibrating rhythmic air produced by complex and delicate machinery using discord.py?
defined outside of the command scope? Yea, that is a possibility, but as he told, the bot doesn't send the embed, neither any errors, soo could be an error eating error handler?
Nah
It is just a wrapper for the Discord API
I canβt tell if thatβs a joke
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
yay that worked! I confused somethings
If you mean playing sound, then yes you can vibrate the air molecules using discord.py
pretty sure it doesnt come from the embed
yups
filters?
No
Sorry for the cursed image(on mobile) but this effectively what heβs doing.
And it does exactly what he wants
the fuck u talking about
You guys telling him to rename his variables
seems like i was right am i not ?
#discord-bots message
Did i tell him to?
Did i tell him to?
Eh it is fine to do that since it is a small code with no if statements haha
It becomes a problem when there is conditional programming involved
Look what youβre implying
Ok ok calm down haha.
Cuz if you looked at his code, he was getting something out of the list he wanted lmao
u should learn some code before trying to teach me python buddy
calm down here
Now youβre saying heβs getting it even though you said "without really getting one of the strings from the list"
But ok
cz the variable name was wrong
Damn python elite coder here 
Haha I also missed that one tbh
But the IDE should have warned about that as long as they ain't using IDLE/Notepad π
Jesus Christ did I actually make that big of a fuck up :l
Haha happens my dude
let him be hunter, even the issue author thank'd me but i dont know what this guy is on about
I mean shit bro you donβt gotta be toxic about it
??

π€·ββοΈ whatever
πΏ
Thanks
Is there any better free alternative to host a discord bot (except repl and heroku)?
Nope
no
I don't think so
ps1
Free hosting sucks. Period.
not really, depends for your use cases
True in 99.9% cases. Period.
If you consider raspberry pi free hosting, itβs decent
My bot is only for few servers
raspberry costs much at first tho
LMAO
What about an Xbox 360
it's not really free hosting, you still gotta pay the internet and the electicity


Barely any electricity
Mines been running for months, barely uses any
it would be a lot lot cheaper to get a VPS
Me whose internet is down for like 2 days every month: 
I also pay for food to keep me running.
π
Initially? Yeah but overtime vps overtakes the cost
how??
Itβs like one of those maths problems
i'm talking about the vps's electricity + internet bill, not how much you pay go buy one
Vps are like what 10 or 20 per month right
so I'll stick to heroku for now
can even be 5 bucks for a really good on on ovh
haha he is talking about owning a VPS
Its not your raspberry that will put you out of money for what it consumes lol
I was about to say
5$/month for a year = 60$
raspberry at first (40$) and the electricity and internet for this small thing isn't more than 20$/year
so a raspberry is cheaper for more than 1 year
Digital Ocean
Saved your energy (:
Your whole time passing coding on your pc will cost you more than the raspberry
I heard vulur is a good vps
yes it is
If we assume Rpi costs 150, and we assume VPS is 10/month, in 15 months the VPS becomes more expensive than the raspberry Pi
Expensive
You can always use K8 Clusters
AND you can use a raspberry for many things
so your rpi only uses 1.66 bucks of electricity and internet per month? π€¨
noidea
Dunno about internet, but electricity is somewhere there
even if that were to be true, a VPS is more reliable than a rpi (especially depending on where you live)
Don't u all think this is going a bit off topic
but you can use a raspberry for so many things
Canβt argue with that
raspberry pies are built so they dont require that much electricity
oh i see
but the internet 
Just throw Linux webserver on it
Β―_(γ)_/Β―
Stays online forever no restarts
Dont you have an internet subscription?
nop
It started as a simple VPS Question and now there is a whole debate on R-Pi vs VPS
Guess I've started small war.
In any way your pc will cost you way more than the raspberry 
Civilized discussion

no clue
es. Can say that
Ok ok everyone, if u wanna contiue this, take it to an OT channel please haha
Unless you use a potato as a pc
Most people already have internet subscription, a raspberri pi wonβt increase the price
So what's the conclusion?
Ppl gotta learn about internet & power consumption
Free vps = bad
Never ask questions related to free VPS's again
Paid vps = good
π
I was about to refer to this but its fine.
just check the pinned message about it and don't ask any questions
Power consumption is a completely different matter
Heroku is intended for website hosting
They are talking about electricity bill and internet bill
AWS is probably the best VPS imo
it's still good for a small bot
I checked. Every solution was paid LOL.
of course
Yeahhh, but if you can, VPS is way better
why do you think that is
What did you except?
Today's Lesson: Never ask questions about Free VPS's as long as you don't wanna start a civil war discussion on Raspberry Pi vs VPS.
Understood kids?
ovh and linode are really good too, @unkempt canyon is hosted on linode, R. Danny (from the dpy server) is hosted on ovh
Good free hosting? Better luck getting Santa to show up for Christmas
Yes lmao
Good Boy :kek:
exactly, if
somebody hosting a discord bot for you won't be non-profit for them, but it will cost them some money
why would they do that
How to make a discord bot?
they could ask for some monthly nitro
Some people just donβt have the money for a vps and itβs understandable if you use heroku
then it's again, not free
or don't have a cc/paypal/bitcoin because they're underage
Buying is cheaper than giving them nitro monthly even when u yourself don't have it π
Exactly. 10$ is too much(for a month) where I live.
ah
Same
i meant that the one that offers to host asks for monthly nitro
ah okay
that way they make some profit
The cheapest vps I know is for 5 bucks a month
but it's not free then anymore
same, that being ovh
Β―_(γ)_/Β―
Heroku faster or repl for discord bot?
^^^
from my personal experience with both, i find heroku indefinitely better than replit, here's some reasons why: your bot won't die every 16h (will die every 22-24h+) and when it dies it doesn't take like 15 minutes to come back on (heroku takes like 10s, replit can even take 30m), heroku is a lot faster and more responsive and you can have a better connection if you set your heroku app's region to america (lowest you can get is even 10ms, highest i've got was ~30ms, on replit it's a lot higher)
mongodb >>>
faster and can store more data types
okay
tanks
hi someone know why my all commands don't working?
wth
tf is that code
why are you writing intents so many times
also explain "don't working", can't help you if you don't tell me exactly what's wrong
should still work even tho it sucks
ikr
what commands do you have?
what did you type in discord?
"All commands don't working"
How to react to a embed?
again, that doesn't tell me anything
you react to the message, not the embed
simply add a reaction to the message
"All commands don't working"
this doesn't help
that does not tell me anything from the code you provided
yea i change client to bot and now nothing working
I know but idk how i to do it but i know the command
you said nothing worked even before
give us more code, maybe an error
how you tried to invoke the command
I don't talk it's never working
em = discord.Embed(description='hi')
msg = await ctx.send(embed=em)
await msg.add_reaction('πΏ')
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.
Thanks i was confused
np
are you running the bot?
Yes
that's a lot of things in on_ready
well, they didn't ask for ytdl help so the rules don't apply yet
and it's also copied
lol
oh wait no there are different stuff there
found your problem
on_ready doesn't have process_commands
message
add await bot.process_commands(message) at the bottom of your on_message event
still nothing
did you save and restart
ya
and the commands aren't working even now?
no
any errors?
no
then idk
Alvesok , you probably indented it wrong , make sure it's on the first level inside the function
.
can i build a bot in discord only with python?
bruh
Yes, you already got answered
No
What. how? like:
bot.load_extension("cogs/moderation.ban")
I'd rather learn from books than from videos
cogs.moderation.ban I guess
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
I will see a python tutorial in youtube name: [ Python Tutorial - Python for Beginners [Full Course] ] is it a good video?
i tried. doesnt work
You already asked
@craggy talon Here you can learn
ok
what can I learn best to program?
ohh sorry
Huh?
working code is just cogs.ban but i want from two folders, from cogs and from the cogs folder i have mod folder and from the mod folder i want ban.py
Search on Google
what's the use of cogs tho?
Makes your code organized
but, i can simply make async functions in different files, and await them in the main file
What
umm.....like I make an asynchronous function named joinvc in discordpy format in a file named music.py, I can then import that file into main.py and use the function using
@client.command()
async def join(ctx):
await music.joinvc(ctx)
By organizing code I mean, make specific named files like, commands, events, misc, utility and then add the commands to their appropriate files
hmm, but the commands still remain in the other files
hi i need some help
def get_meme():
url = "https://api.imgflip.com/get_memes"
response = requests.request("GET", url)
json_data=json.loads(response.text)
meme= json_data
return(meme)
@client.command()
async def meme(ctx):
meme=get_meme()
em= discord.Embed(meme)
await ctx.send(embed=em)```
this is my code
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 91, in meme
em= discord.Embed(meme)
TypeError: __init__() takes 1 positional argument but 2 were given
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 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: TypeError: __init__() takes 1 positional argument but 2 were given
this is the error
how do i fix it?
discord.Embed takes two positional argument, thats what the error says
wdym
discord.Embed(title="smh", description="optional smh", color=ctx.message.author.color or discord.Color.blue())
what does the meme var return?
this is the mistake
i want it to retuen a meme
but you are returning the text ,-,
is there another way other than embedding
!d discord.File
class discord.File(fp, filename=None, *, spoiler=False)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.
Note
File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
ctx.reply(file=discord.File(get_meme())) @ornate lichen
futuredate = datetime.now() + datetime.timedelta(seconds = time)
AttributeError: type object 'datetime.datetime' has no attribute 'timedelta'
first try printing get_meme()
did you import datetime from datetime?
ye
async def meme(ctx):
ctx.reply(file=discord.File(get_meme()))```
I suck at datetime
i changed to this
try running it
still doesnt work
print(get_meme()) before sending anything
whr
before ctx.reply()
I think your lacking a bit of knowledge
exactly
i mean like i cant print picture in the terminal
Hes saying to debug the command with print lmfao
Not yet let him debug it
sure
What is he trying to do?
Get a random meme?
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 91, in meme
ctx.reply(file=discord.File(get_meme()))
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/file.py", line 73, in __init__
self.fp = open(fp, 'rb')
TypeError: expected str, bytes or os.PathLike object, not NoneType
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 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: TypeError: expected str, bytes or os.PathLike object, not NoneType```
yes
From a file
wait
api
@slate swan
Which one exactly?
this
I see
imgflip
it returns json format for me
Why not use asyncpraw
def get_meme():
url = "https://api.imgflip.com/get_memes"
response = requests.request("GET", url)
json_data=json.loads(response.text)
meme= json_data
print(meme)
@client.command()
async def meme(ctx):
get_meme()
ctx.reply(file=discord.File(get_meme()))```
for
[Latest] What is a Cog?
The base class that all cogs must inherit from.
A cog is a collection of commands, listeners, and optional state to help group commands together. More information on them can be found on the Cogs page.
When inheriting from this class, the options shown in CogMeta are equally valid here.
Why use Cogs?
Cogs will help make your code much more organized and nicer, this will be especially helpful if you are collaborating with other developers in your discord bot or your bot is open source. This will even help you in the future as when you add more features to your bot it will help you understand your code.
To learn how to use a cog ?tag cog
Documentation:
Latest: https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#cogs
Async: Shouldn't you be on Latest?
mhm
Hey everyone!
I'm trying to make a discord bot whose status updates with the price of a coin, i was successful until I ran into this "error" after a bit of testing, the bot goes offline, but the script continues to run :/
socket.send() raised exception.
You dont have to use json for asyncpraw and you don't have to download anything but have to make api calls but just put a cooldown
how do i use datetime.now and timedelta at the same time
Have you tried try: except:
you lost me
?
lmao
have i tried those where
ok i see
Not indented cause of disc
main.py:91: RuntimeWarning: coroutine 'Context.reply' was never awaited
ctx.reply(get_meme()["data"])
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
await ctx.reply
yea i did it
and you need to add_field it, since its a url
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In content: Must be 4000 or fewer in length.
Anybody got a good json command tutorial i keep forgetting all the commands?
import requests
import json
def get_meme():
url = "https://api.imgflip.com/get_memes"
response = requests.request("GET", url)
meme =json.loads(response.text)
return(meme)
url = get_meme()["data"]["memes"][0]["url"]
em = discord.Embed(title="drake meme")
em.add_field(url=url)
await ctx.reply(content=None, embed=em)```
you can use random module to change names and url everytime
documentation
best
The bot still crashed :/
must have printed an error
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: add_field() got an unexpected keyword argument 'url'
Thx
sorry, change add_field to set_image
ret = await coro(*args, **kwargs)
File "main.py", line 91, in meme
em.add_field(url=url)
TypeError: add_field() got an unexpected keyword argument 'url'
My bad
ok
@upbeat otter good luck with the problem solving
aww, thank you dear

you, don't, I can help you with this
how
does discord ratelimit changing status?
You can get randoms memes with asyncpraw or search for a keyword in a post
create an imgflip account
store the usename and password in variables, get your use agent
make the request
I know, that's why, i'm sending code lmao
then i just kept getting 401
just create an account for imgflip
ok
dont spoonfeed
im still getting this:
socket.send() raised exception.
well, thats a point, but you have to read the whole documentation
well, then help him
!pypi asyncpraw
so do you guys know if discord allows x status changes / x time ?
https://www.reddit.com/r/memes.json cant i just replace that url with this
its a hole list
whole
@upbeat otter
yes, changing status every 5 or 10 seconds is bad
i see, if i do like every minute, would that stop that error?
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:
i have
there
k thanks
ye and then do this
i change delay to like 200?
wdym
coroutine asyncio.sleep(delay, result=None)
^
SyntaxError: invalid syntax
asyncio is invalid
delete coroutine
ok, thanks
its asyncio.sleep(delay)
thanks
k
180s wouldnt hurt either
π
that would still build up some stress on the bot
delay is supposed to be in seconds
yes i know thats why i said 3min
show your whole code
5min is best
import discord
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio
import requests
import json
import time
import datetime
# configuring discord bot
PREFIX = ("$")
client = commands.Bot(command_prefix = PREFIX, description = 'Hi')
# bot status
@client.event
async def on_ready():
while True:
# defining vitex api
url = "https://vitex.vite.net/api/v1/exchange-rate?tokenSymbols=VITC-000"
# connecting to the api
response = requests.get(url)
# setting up parsing & variables
delay = 120
response = requests.get(url)
data = response.text
parsed = json.loads(data)
data = parsed["data"]
type(data)
usdRate = data[0]['usdRate']
localtime = time.asctime( time.localtime(time.time()) )
asyncio.sleep(delay)
# changing status
await client.change_presence(activity = discord.Activity(type = discord.ActivityType.watching, name = str(usdRate) + "$"))
# printing VITC value!
print("<===============Made by:5am===============>")
print("VITC's price @ " + str(localtime) + " is $" + str(usdRate))
client.run('TOKEN')
sorry if its sloppy
this is really my first time
you can just use tasks.loop for this
instead of the function?
!d discord.ext.tasks.loop
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
Don't use requests in a bot, use aiohttp
Use aiohttp.
requests and urllib are blocking. Do not use these libraries within your asynchronous code.
(http://discordpy.readthedocs.io/en/latest/faq.html#what-does-blocking-mean)
discord.py uses aiohttp, so it should already be installed. An example of code using aiohttp and discord.py:
async with aiohttp.ClientSession() as cs:
async with cs.get('https://httpbin.org/json') as r:
res = await r.json() # returns dict
await ctx.send(res['slideshow']['author'])
For more help, see aiohttp's documentation: http://aiohttp.readthedocs.io/en/stable/
@bot.command()
async def deletechannel(ctx, channel: discord.TextChannel = None):
author = ctx.message.author
channel = channel.replace('<','')
channel = channel.replace('#','')
channel = channel.replace('>','')
channel=client.get_channel(int(channel))
if channel == None:
await ctx.send(":Skull_Error: γ’ Mention a channel first")
nuke_channel = discord.utils.get(ctx.guild.channels, name=channel.name)
def check(message):
return message.author == ctx.author and message.channel == ctx.channel
await ctx.send('**Are you sure that you want to delete this channel? `type yes or cancel`**')
msg = await bot.wait_for('message', check=check)
if msg.content == "yes"
if nuke_channel is not None:
new_channel = await nuke_channel.clone(reason="Has been Nuked!")
await new_channel.send(":Success_Green_skull: γ’ Channel nuked succesfully")
if msg.content == "cancel"
await ctx.send(":Skull_Error: γ’ Nuke canceled succesfully")
Error :
learn python please
no
i tried running the example code and i got an error
async with aiohttp.ClientSession() as cs:
^
SyntaxError: 'async with' outside async function
There should be a colon instead of a comma
It needs to be in an async function like the error says
why, just why, he deserved that
Basic mistakes can happen by anyone
he put a comma
yea, do you practice with those errors when you're learning python? yes
oh i see it, thanks man
btw discord nukes are against tos
Well, I have also done a lot of basic mistakes while coding
its a delete channel cmd
that you took from a discord nuke bot lmao
but you know how to fix them correct?, like cmon who does not know how to fix an invalid syntax?
uh?
the command says it
its not
bro chill i just did a mistake
why would i?
its literally an invalid syntax error
Good point, hopefully they will learn from it
bro its a invalid syntax error just chill
why is it called nuke_channel then
thats the point LMFAO
hes just deleteing a channel to delete all the messags and then creating a clone of it so its a fresh new channel
better now?
seems weird how someone would call a channel that ngl
instead of using purge(10000)
thats what he defined it as
@slate swan your making a anti nuke bot
what
to fix the damages of a nuke?
im just making a delete channel command
alr
no
just a delete channel
but your making a clone of the channel
ye
bc when im gonna delete this channel i want to make another one
yea i know what you mean
but now i have this error but it seems that the lines are ok
!indents
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
@kindred epoch sorry for the ping but do you get friend request from this server from random people who never talk in chat they just add me and they dont even dm when they can lmao
It wants the return there?
damn aiohttps is way harder than requests
nope
just me ig
ye
why
why
?
@bot.command()
async def deletechannel(ctx, channel: discord.TextChannel = None):
author = ctx.message.author
channel = channel.replace('<','')
channel = channel.replace('#','')
channel = channel.replace('>','')
channel=bot.get_channel(int(channel))
if channel == None:
await ctx.send(":Skull_Error: γ’ Mention a channel first")
return
delete_channel = discord.utils.get(ctx.guild.channels, name=channel.name)
def check(message):
return message.author == ctx.author and message.channel == ctx.channel
await ctx.send('**Are you sure that you want to delete this channel? `type yes or cancel`')
msg = await bot.wait_for('message', check=check)
if msg.content == "yes":
if delete_channel is not None:
new_channel = await delete_channel.clone(reason="Has been Nuked!")
await new_channel.send(":Success_Green_skull: γ’ Channel deleted succesfully")
if msg.content == "cancel":
await ctx.send(":Skull_Error: γ’ Delete channel canceled succesfully")
error :
i think you forgot :
The indentation is wrong
i think its just discord
what
before await
One of the ctx.send is in the check function (which is not async)
where
oh yeah
good eye
in def check
And you dont need to use bot.get_channel when you already have the instance
does commands.check not work anymore
TextChannelConverter will convert the parameter to an textchannel object
it does
i have a command check that makes a command only work for me
yet everyone in this server im in can use it
here?
show it
i think this will not work lmao
await uses async
Return will stop the function execution, any code after that won't run
@kindred epoch
oh its online
@bot.command()
async def deletechannel(ctx, channel: discord.TextChannel = None):
author = ctx.message.author
channel = channel.replace('<','')
channel = channel.replace('#','')
channel = channel.replace('>','')
channel=bot.get_channel(int(channel))
if channel == None:
await ctx.send(":Skull_Error: γ’ Mention a channel first")
delete_channel = discord.utils.get(ctx.guild.channels, name=channel.name)
async def check(message):
return message.author == ctx.author and message.channel == ctx.channel
await ctx.send('**Are you sure that you want to delete this channel? `type yes or cancel`')
msg = await bot.wait_for('message', check=check)
if msg.content == "yes":
if delete_channel is not None:
new_channel = await delete_channel.clone(reason="Has been Nuked!")
await new_channel.send(":Success_Green_skull: γ’ Channel deleted succesfully")
if msg.content == "cancel":
await ctx.send(":Skull_Error: γ’ Delete channel canceled succesfully")
this is correct?
i think so idk
why have you defined channel 3 times
this is how i grabbed usdRate from data using requests
usdRate = data[0]['usdRate']
I tried doing that with aiohttp but i get this error:
usdRate = data[0]['usdRate']
KeyError: 0
thanks in advance for putting up with idiocy
!or
When checking if something is equal to one thing or another, you might think that this is possible:
if favorite_fruit == 'grapefruit' or 'lemon':
print("That's a weird favorite fruit to have.")
While this makes sense in English, it may not behave the way you would expect. In Python, you should have complete instructions on both sides of the logical operator.
So, if you want to check if something is equal to one thing or another, there are two common ways:
# Like this...
if favorite_fruit == 'grapefruit' or favorite_fruit == 'lemon':
print("That's a weird favorite fruit to have.")
# ...or like this.
if favorite_fruit in ('grapefruit', 'lemon'):
print("That's a weird favorite fruit to have.")
change the arg to m and check if the author is in the list of ids
He has not defined it, he has assign it
@discord.ui.button(label=None,
custom_id='kill1',
style=discord.ButtonStyle.blurple, emoji=':swblaster:')
async def verify(self, button: discord.ui.Button, interaction: discord.Interaction):
how to make a check here for the member who called the command, well, only he can press the button ??
the author isnt in the list
and wdym change the arg to m
it doesnt work bruh
thats what i mean, add the ids in a list and then check it
do you not know what an arg is?
arguement
no errors
and whats the arg in that def
@magic ore if youre online to help i'd really appreciate it
@slate swan
def terror(ctx):
return ctx.message.author.id == 813989866236149770 or 853544955300806657 or 431427182926102528 ```
?
its weird cuz their user id is py 481245481012559894
which is not in that list
so how would they have access to the commands
ik the problem
whats the problem
remove message after ctx
and this will solve all my problems?
cuz they never used to have access to this until now which is really weird
You are using or improperly
^
so how should i use it
thats why i said add all those ids in a list and check if the author is in that list
data is a dict that does not contain the key 0
hmm, so should remove the [0] thanks
usdRate = data['usdRate']
KeyError: 'usdRate'
I GOT IT
(all by myself)
i deserve a sticker
no.
sad
import aiohttp
import asyncio
import discord
from discord.ext.commands import Bot
from discord.ext import commands
import datetime
PREFIX = ("$")
client = commands.Bot(command_prefix = PREFIX, description = "VITC Price")
@client.event
async def main():
async with aiohttp.ClientSession() as session:
api_url = "https://vitex.vite.net/api/v1/exchange-rate?tokenSymbols=VITC-000"
async with session.get(api_url) as resp:
api_data = await resp.json()
data = api_data["data"]
usdRate = data[0]["usdRate"]
print(usdRate)
await client.change_presence(activity = discord.Activity(type = discord.ActivityType.watching, name = str(usdRate) + "$"))
asyncio.sleep(10)
# printing VITC value!
print("<===============Made by:5am===============>")
print("VITE's price @ " + str(localtime) + " is $" + str(usdRate))
asyncio.run(main())
client.run("token")
error:
await self.ws.change_presence(activity=activity, status=status, afk=afk)
AttributeError: 'NoneType' object has no attribute 'change_presence'
might not be necessarily a python problem, but i still wanted to ask how i can get around this error:
TypeError: Cannot read properties of undefined (reading 'extend')
at Object.<anonymous> (D:\Coding\schedule_notification_client_1\node_modules\discord.js-commando\src\extensions\message.js:7:29)
at Module._compile (node:internal/modules/cjs/loader:1095:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1147:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (D:\Coding\schedule_notification_client_1\node_modules\discord.js-commando\src\registry.js:5:25)
at Module._compile (node:internal/modules/cjs/loader:1095:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1147:10)
its a js error which you are asking in the python server
well mb, im so new that i thought its just a really small problem so maybe someone here would know how to fix this
bruh huh, its a javascript error, why are you asking it in the python server, ask it in the discord.js help server or js server
show it
@client.event
async def on_member_join(member):
guild = client.get_guild(904718822462857256)
welcome_channel = guild.get_channel(905474719690661898)
await welcome_channel.send(f'{member.mention} Welcome!')
intents on btw
do you have any on_message events?
show ur whole file where that is located
!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.
