#discord-bots
1 messages Β· Page 508 of 1
how
client.get_channel(mychannel) returns a discord.TextChannel instance
and?
save it in a variable named x for example
then await x.send("content")
what should that variable be equal to?
to the client.get_channel()...
okok
so now you got x an instance of discord.TextChannel
yes
not really
can you show the current code?
thn what
async def on_command_completion(ctx, channel: TextChannel, *, mylogs):
await ctx.send("{} used {}".format(ctx.author, ctx.command.name))
mylogs = client.get_channel(mychannel)
now do await mylogs.send("whatever")
you don't need that await ctx.send("{} used {}".format(ctx.author, ctx.command.name)) lol
also look at the args
change to on_command_completion(ctx):
async def on_command_completion(ctx, channel: TextChannel, *, mylogs):
NameError: name 'TextChannel' is not defined
okok
i fixed my problem
does it comes after the cmd?
what is it?
^
SyntaxError: invalid syntax```
i have a list of Message objects and i want to sort them based on creation_date attr. could someone help with that?
NameError: name 'mylogs' is not defined
how to do it?
did u removed the variable too?
yes
i was adding an on_message event before the command and forgot to add "return" to the end of it
u shoud've kept that
i mean what is the cmd?
help
does that code sorts out the help part?
help command sends an embed with the commands listed
oh
i wanted tht too
thanks
dont u go and copy my code tho, thats not how ya learn
u gotta understand it or you wont be able to fix any errors u run into
i know i know
good
but i needed to learn how to do the thing
if u wanna copy/paste it thats fine, but u gotta break it apart and learn how it works
you cant just copy the code and call it good
not a problem
k
i can understand
I can't, could you help me better?
send your current code please
k
@client.event
async def on_command_completion(ctx):
await ctx.send("{} used {}".format(ctx.author, ctx.command.name))
await client.get_channel(893147273884729345)
get channel is the problem
the get_x methods aren't asynchronous
now I have to go, as soon as you can if you can tell me in dm how to do it, I will not be able to read the messages here
you don't need await for get_x methods
if you remove await from your last line here it should work
what is the error?
can i see?
yo
I need a suggestion on how to use mongodb with discord bot. Should I create a file with functions inside that will call a database or use something else?
???
i am working with postgres
asyncpg
and it is showing this
when i am loading a row's object
get_channel doesnt return a coroutine
do record_variable['prefix']
there was no errors when i ran it
to render?
get_channel doesnt return a coroutine, it would raise an error
after cmd?
!e ```py
import asyncio
def get_something(id: int):
return id
async def main():
await get_something(123)
asyncio.run(main())
@hasty iron :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 9, in <module>
003 | File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
004 | return loop.run_until_complete(main)
005 | File "/usr/local/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
006 | return future.result()
007 | File "<string>", line 7, in main
008 | TypeError: object int can't be used in 'await' expression
use ctx.prefix
do you forget this easily
what is ctx.prefix?
bot.prefix??????
no u told that
The prefix that was used to invoke the command.
let me see it properly :/
The prefix that was used to invoke the command.
what do you want to see?? i dont understand
Someone can help me please?
@hasty ironpy if before.permissions != after.permissions: diff = set(after.permissions).difference(set(before.permissions)) for perm, value in diff: if value == True: list1.append(perm) else: list2.append(perm) embed.add_field(name = "Added Permission(s):", value ='\n'.join(list1), inline = False) embed.add_field(name = "Removed Permission(s):", value ='\n'.join(list2), inline = False) await logChannel.send(embed = embed) this works when perms are added and removed in one go, but doesnt when only perm is added or when perm is removed
return the prefix used to invoke the command
I had told u before but u told me u had some urgent work and then forgot, soo I don't really remember now
"ohh" man
Lmao
what did you ask about
.....?
hm?
hmm
@bot.command()
async def test(ctx):
if ctx.author.status == dnd:
await ctx.send("oNligne")``` how to change DND to online ?
better discord again π
its not, copium
siet
That's a modified client right there
sorry
Wdym sorry
deleting it wont change the fact that 3 people saw it
@bot.command()
async def test(ctx):
if ctx.author.status == dnd:
await ctx.send("oNligne")``` how to change DND to online ?
hmm but the theme is weird
he already showed it before in a bigger ss
because bot send DND
yeah i saw it
how to connect postgres with heroku
i was using
pgadmin 4
but when update in heroku
it is saying address not connected
so someone can?
errors?
When how to change DND to online?
@bot.command()
async def test(ctx):
status = ctx.author.status
await ctx.send(status)```
anyone help!
hey I am making a command which you run, I then want the bot to ask a question such as:
What is your favourite color?
and wait 30 seconds for a response before stopping, what is the easiest way to achieve this?
I can think of some complex ways but i'm sure there must be some simpleish way built into pycord/discord.py
!d discord.Client.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
finally not using better discord
replied to this
your status is dnd
How can i define aiohttp?
import it?
import it
help
what's error
no error
can you print diff
it works for both added and removed perms , but if only perms are added or only removed, it doesnt work
sends this error
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embed.fields.0.value: This field is required
{('read_messages', False)}
Yo!! guys
does this work?
Can't somehow be changed to Online so that it writes?
Can't somehow be changed to Online so that it writes?
yes
is it bot status?
Bot send DND
dnd is your status and it is do not disturb
aaaa
async def on_ready():
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.competing, name="slums"))
print("daddy slums is online.")``` why does it say client is not defined the variable?
have you copied the code?
no i done it myself
do you have bot = commands.Bot(...)?
nope
show the whole error
I am trying to create an admin bot. I have a csv file of cuss words. How do I ban someone who uses any of these cuss words?
client = commands.Bot(command_prefix = ";", intents=intents) i got this
β||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||https://khadz.fuckedyourmom.today/ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
can you show the full code
for the client.event?
looks sus
yeah lol
no, the entire file code
alright
from discord.client import _ClientEventTask, Client
from discord.ext import commands
import json
import os
import os
intents = discord.Intents.default()
intents.members = True
@client.event
async def on_ready():
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.competing, name="slums"))
print("daddy slums is online.")
client = commands.Bot(command_prefix = ";", intents=intents)
if os.path.exists(os.getcwd() + "/config.json"):
with open("./config.json") as f:
configData = json.load(f)
else:
configTemplate = {"Token": "", "Prefix": ";"}
with open(os.getcwd() + "/config.json", "w+") as f:
json.dump(configTemplate, f)
token = configData["Token"]
prefix = configData["Prefix"]
initial_extensions = []
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
initial_extensions.append("cogs." + filename[:-3])
if __name__ == '__bot__':
for extensions in initial_extensions:
client.load_extension(extensions)
client.run(token)```
bye
You defined client after the event.
nice domain btw
ty XD
!e
print(e)
e = "e"
@dapper cobalt :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | NameError: name 'e' is not defined
fixed
how long have you done programming for 
You can't use a variable before you've defined it.
β||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||https://khadz.fuckedyourmom.today/ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
how do i fix this now?
β||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β|https://khadz.fuckedyourmom.today/ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
xd
KeyError means not found. Check if you have "Token" where you are trying to find it.
Ur really into moms huh
LOL
alright
βDJS.||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||βhttps://discord.gg/dpy
Wrong URL, wait.
something is weird
ohhh
wdym by where you are trying to find it
does discord removes the link and keep the embed now?
its just invisible characters + a link that discord converts to an embed
Either in file, or dict.
It's called spoiler abuse.
ehh no
No, that's just abusing spoilers.
||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β|https://top.gg
how
yeah got it
someone will get banned soon with it
βJavaScript.||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||βhttps://top.gg```
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββThat's how it actually looks.
βββiβ do not have Tokenββββββββββββββββββββββββββββββββββββββββββββββββββββ
bro can you learn a fucking language
ye, i can
||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||||β||β@high flame
!e print(hmmm why doesnt this work)
@manic wing :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | print(hmmm why doesnt this work)
003 | ^
004 | SyntaxError: invalid syntax
here we go again
which language? its the absolute basics to define a variable before its used
you have done a day of python and expect to make a discord bot
!e
my_dict = {"name": "Seif Wessam"}
print(my_dict["age"])
@dapper cobalt :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | KeyError: 'age'
KeyError because the dict doesn't have "age".
But it does have "name".
!e
my_dict = {"name": "Seif Wessam"}
print(my_dict["name"])
@dapper cobalt :white_check_mark: Your eval job has completed with return code 0.
Seif Wessam
could you suggest me some videos that will help me.
!e
my_dict = {"name": "Seif Wessam"}
print(my_dict["life"])
@manic wing :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | KeyError: 'life'
no.
i can suggest you learn basics for a month
Lmao thanks.
alright, i will then
tell me what i should learn and ill do it
im happy to help you with the basics in a help channel or dms (despite my name) if you need basics help, its just hard to jump into the deep end with python - discord.py is a bit more intermediate
i can give you 10 projects
sure
yes please
Make a game.
i recommend watching youtube videos for each of them
Just kidding haha.
alright
i sent you a friend request fred
Try to learn about dicts. Make a dict variable called "player" and append a health field, shield field, inventory field which should be an array, and level field.
@commands.command()
async def join(self, ctx):
if ctx.author.voice is None:
await ctx.send("Bot doΕΔ
czyΕ do kanaΕu gΕosowego!")
voice_Channel = ctx.author.voice.channel
if ctx.voice.channel is None:
await voice_Channel.connect()
else:
await ctx.voice_client.move.to(voice_Channel)```wtf discord.ext.commands.errors.CommandNotFound: Command "join" is not found
Should look like this:
player = {
"name": "Player 1",
"health": 100,
"shield": 50,
"inventory": ["sandwich", "sword"],
"level": 1
}
@slate swan
Did you reload the cog?
Would be a rookie mistake.
mhm wait
ah yes i see
you got any good beginner course python videos i could perhaps watch?
- make a window with tkinter (its called tkinter.tk) -> watch tk tutorials
- learn tkinter in general
- make a window with pyqt5 (why not)
- make a class which will give a random name and some random jazz (just watch python class tutorials)
- make balls bounce around a tkinter window
- use the module
requeststo get a random joke from an api (just google python requests api get joke) or something - use sqlite or mongodb (databases) to transfer data to and from the databases - plenty of tutorials
- learn dicts and lists (dict indexing (dict[]), dict keys, etc)
- learn these modules: (not super in depth but just a little bit):
- time
- random
- numpy
- simpleeval
- fully comprehend the uses of
dirand completely grasp attrition, properties of objects. Everything in python is an object."HI"is astringwhich has attributes likeupper, lower, split
.
these should take a month or so, if you need any help you can ask me
That's a lot of tkinter
Traceback (most recent call last):
File "c:/Users/Uzytkownik/Desktop/Dawid Orginalny/Python/Avexa Music/main.py", line 8, in <module>
import music
File "C:\Users\Uzytkownik\AppData\Local\Programs\Python\Python38\lib\site-packages\music\__init__.py", line 1, in <module>
from .utils import H
File "C:\Users\Uzytkownik\AppData\Local\Programs\Python\Python38\lib\site-packages\music\utils.py", line 5, in <module>
from . import core
File "C:\Users\Uzytkownik\AppData\Local\Programs\Python\Python38\lib\site-packages\music\core\__init__.py", line 1, in <module>
from .functions import *
File "C:\Users\Uzytkownik\AppData\Local\Programs\Python\Python38\lib\site-packages\music\core\functions.py", line 275, in <module>
foo = n.linspace(-1, 1, Lt/2, endpoint=False)
File "<__array_function__ internals>", line 5, in linspace
File "C:\Users\Uzytkownik\AppData\Local\Programs\Python\Python38\lib\site-packages\numpy\core\function_base.py", line 120, in linspace
num = operator.index(num)
TypeError: 'float' object cannot be interpreted as an integer``````py
import discord
from discord import channel
from discord.channel import VoiceChannel
from discord.ext import commands
from discord.ext.commands.core import command
from discord.player import FFmpegAudio
import music
Should've also recommended smth like making a tic-tac-toe or a rock-paper-scissors or something
a great starting modle
they teach less
But they're fun to do
And still teach you something
The easiest way to learn something is if it's enjoyable and fun, so they'd be a great learning experience, especially if they compare their code with someone else's, then they can improve their skills even further
yeah, but im being less specific so that problems can just be ignored - problem in a rock paper scissors game? youβre stuck and cant move on
ive been vagueish meaning they can learn all they can
Understandable
What is FFmpegAudio used for?
Isnt that against Spotify tos
Why do you think that the problem is with your imports? Did you read the last 2 lines of the traceback?
yes
?? why do you have it??
what?
learning OOP would be very useful
what is that?
the lib isnβt even usable with discord bots
Object Oriented Programming
do you know what youβre doing?
could you dm me some beginner tutorials?
make an os or programming language.
β¦
error 404: beginner definition not found
How do you manage to do that
making an os with python is not possible(?)
i don't know
you need something lower level
ah yes not
like C and assembly
my suggestions are bad, don't dm lol
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
!projects
Kindling Projects
The Kindling projects page on Ned Batchelder's website contains a list of projects and ideas programmers can tackle to build their skills and knowledge.
alright
I said that in the 10
I'm getting a syntax error on the else:, how can I stop this? is there something i would need to add to the end of the try: like pass, continue etc or do I need to add in a exception?py if joincount[2] > 3: embed = discord.Embed(title = "Member Banned!", description = f'{member.name}#{member.discriminator} account is **{acc_age.days}** days old and has joined the server {joincount[2]} times so the member was banned by raidmode.') await member.ban(reason = f"Raidmode enabled: {member.name}#{member.discriminator}'s account was deemeed too new by your raidmode configuration. The required age is {data[15]} days old and this users account is {acc_age.days} days old. You can check the current required age with the modconfig command. This user has also joined the server {joincount[2]} times which resulted in their ban.") await raid.send(embed = embed) try: await member.send(f"This server has raidmode **active** and requires users have a account that is older than **{data[15]}** days old and to have not joined more than **3** times. As your account is less than the servers threshold and you have joined {joincount[2]} times you have been banned.") else: embed = discord.Embed(title = "Member Kicked!", description = f'{member.name}#{member.discriminator} account is **{acc_age.days}** days old and so the member was kicked by raidmode.') await member.kick(reason = f"Raidmode enabled: {member.name}#{member.discriminator}'s account was deemeed too new by your raidmode configuration. The required age is {data[15]} days old and this users account is{acc_age.days} days old. You can check the current required age with the modconfig command.") await raid.send(embed = embed) try: await member.send(f"This server has raidmode **active** and requires users have a account that is older than **{data[15]}** days old. As your account is less than the servers threshold you have been kicked.")
try pairs with except
always
try:
print(this wont work)
except:
print('no syntax error!')
okay, i don't know how or why but my previous implementation didn't error without the except
it did, you just probably didnt read the error correctly
try always goes with except
why when i add reaction β¬ οΈ it not work?
Here's code
https://hastebin.com/hajiquqesu.py
im pretty sure you've asked this same thing multiple times
you could try giving...more information
so...more people can help
yea because nobody want help me :/
raise ClientException(executable + ' was not found.') from None
discord.errors.ClientException: ffmpeg was not found.
no, its because you just paste this crap here with 0 extra information; whats the error, whats the code around it, etc
How i can make help command using reaction - if you click page changing? etc
linux or windows
windows
download ffmpeg
in cmd?
many different ways, depends how you go about doing it
yea i know but which is the best?
what can you recommend to me?
um
can i see your entire code for the help command
ill just tweak it
what
FFMPEG is an incredibly powerful bit of command-line software, but if you've never 'installed' it before, or are used to command-line software then this may be something more than a little confusing for you.
FFMPEG: https://www.ffmpeg.org/download.html
7-Zip: https://7-zip.org/download.html
- gyan.dev Downloads: https://www.gyan.dev/ffmpeg/buil...
https://hastebin.com/foxuwatevi.py
currently it looks like this because I keep wondering how to do it correctly
okay, how would you like me to help? a) give tips, pointers b) rewrite your code c) offer other options d) just write you a new help command
im asking how they want help instead of just spoonfeeding
did you see their code, its pretty far off the mark
b or d because I don't think what I have done will work very well
and i need guidance
ye im beginner : /
im still learning
then help them rewrite it?
not spoonfeed
im gonna rewrite your code and list out what I did to change it
basically spoonfeeding wow
Okr
mate if he wants to be spoonfed (which he does, as he said), then he can - and I'm saying what I did to change it, ill explain it in depth + ill leave a couple errors so its not completely perfect. Also, I don't see you helping him
What's wrong with it if I will understand exactly how this code works?
letβs see your in-depth explanation
How long PayPal send money to bank?
!ot
Off-topic channels
There are three off-topic channels:
β’ #ot0-psvmβs-eternal-disapproval
β’ #ot1-perplexing-regexing
β’ #ot2-never-nesterβs-nightmare
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
Sorry
Well first off, I can notice that parts of your code fit under what we call the or gotcha.
!or-gotcha
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.")
mhm
I can't understand whatever language its in, so you can just write the embeds
okay
im writing it rn
it is in Polish so you can don't understand
okayy
im only going to add the emojis controlled help to the default help (you can do the rest)
Okay
how many commands do you have
Emoticon control is probably the most important for me
a lot and i have plan to divide it into categories like 4fun administrative info etc. You know what I mean?
with emoji user can switch categories
message editing to another embed clear reactions add new reactions etc
Can someone help with this prefix issue im having sorry
a lot of discord bots have this system
what kind of issue?
I want to set the command prefix as text other than one character such as !
Ive did this but the bot does not reply to commands anymore
hmm
Is there any way that I can edit msg from within the except? bc it doesn't seem to be getting edited rnpy try: await member.send(f"This server has raidmode **active** and requires users have a account that is older than **{data[15]}** days old and to have not joined more than **3** times. As your account is less than the servers threshold and you have joined {joincount[2]} times you have been banned.") except discord.Forbidden(response, message): msg.edit(embed = embed, content = "I was unable to DM {member} due to their DM's being closed.\nResponse: {response}\nMessage: {message}") and i'm getting this errorpy Traceback (most recent call last): File "/home/snowyjaguar/.local/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event await coro(*args, **kwargs) File "/home/modmail/cogs/events.py", line 220, in on_member_join except discord.Forbidden(response, message): NameError: name 'response' is not defined
Thanks anyhow man 
where is response defined
@brazen seal do you use cogs?
nitro...
no, what is it?
nvm
how do i set my bot's status?
okay
@brazen seal what emojis are
Β¬``
await wiadomosc.add_reaction(party)
await wiadomosc.add_reaction(question)
await wiadomosc.add_reaction(x)
wait i didn't show you this variables wait a second
https://hastebin.com/vowazazude.ini look @manic wing
well it's shown as something to include in the docs https://discordpy.readthedocs.io/en/stable/api.html?highlight=forbidden#discord.HTTPException, I've tried to remove it but that just gives me py Traceback (most recent call last): File "/home/snowyjaguar/.local/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event await coro(*args, **kwargs) File "/home/modmail/cogs/events.py", line 220, in on_member_join except discord.Forbidden(): TypeError: __init__() missing 2 required positional arguments: 'response' and 'message'
you dont need the brackets lol
except discord.Forbidden
π₯³ β β
use those
you can put the emojis in
copy/paste those that i just sent into the code instead of the words
party replaced with π₯³
question replaced with β
@fallow mauve https://hastebin.com/vowazazude.ini
yes but
Thought I might need this anymore
how do you make your bot detect a mention?
idk i just failed at figuring that out a few minutes ago lol
oof
what type of mention ?
mentioning the bot
detect to do what
now i'm mentioning you @fallow mauve
@raven spindle
use on_message and check if the bot is mentioned in message
and respond to it
@brazen seal im really tired so im gonna go to bed now: heres what i've done so far and I can help you in the morning further
https://hastebin.com/vomajepulo.py
I have;
1) added 4 ifs; for sorting if its a command, not a command, general help, and a cog. The cog will help you later, but you can ignore it for now. I havent made the formatting anything good at all, so it will look crap, but i've layed it out nicely so its easy for you to customise it
2) I added docstrings and comments so you can see whats going on at all times
3) I made it loop through all commands and sort it into embeds, and filter each page with list indexing
4) I used bot.get_cog and bot.get_command and bot.commands to help automate the help.
5) I used lambda instead of a def check
6) I didn't add a timeout because I dont think its needed here
7) I added a stop (the :X:)
8) the code is pretty neat and efficient so it wont confuse you as much
9) I just added names, aliases and typehints - you won't understand, thats fine, but its just it will look neater in the future
10) Indexing is extremely neat and an easy way to do pages, so thats what I did here
ask here if you get any errors, goodnight
Thank you so much, I will get acquainted with it.
and if I have any question, I will write it tomorrow because im go to bed too
so thank you again and goodnight ; )
You can also do (if I remember correctly) something along the lines of discord.Game(string,type)
umm does anyone know how to use slash commands with dpy 2.0 or with nextcord?
Yes it will display that he is playing (according to the type) a game (according to string)
ou
Dpy server
Okay
I'm already in it
lol
https://github.com/EQUENOS/dislash.py this is what I use but I know thereβs a something called discord.Interactions you can import
A Python wrapper for discord slash-commands and buttons, designed to extend discord.py. - GitHub - EQUENOS/dislash.py: A Python wrapper for discord slash-commands and buttons, designed to extend di...
Thanks Imma check it out now
Havenβt used it in a while so not 100% certain it works still. The guy who develops it just recently updated it so it should hopefully work
Okay so it said that it works with dpy 2.0 too
And I'm using nextxord
So I think imma fork it and edit discord to nextcord
Give it a shot
Sadly I'm busy with studying and I have to sleep
Sucks, if I have time later today Iβll hop on pc and test it for you
It would be a great project to fork if it worked
Thanks
You can just replace all instances of discord to nextcord
Sadly it needs Python 3.7+
It's not a big deal ig
Oh
@main quarry actually there is an easier way
Instead of replacing instances just do
import nextcord as discord
from nextcord.ext import commands,tasks
instead of
import discord
from discord.ext import commands,tasks
so it's literally very easy
how do i set status for my bot
ERROR:cogs.error_handler:TypeError: '_EmptyEmbed' object is not callable (In test_sug)
Traceback:
File "/home/snowyjaguar/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/modmail/cogs/some_commands.py", line 24, in test_sug
if search in message.embeds[0].title():```how can I remedy this issue, my code is```py
@commands.command(description = "Lets users locate a specfic suggestion via it's message ID or link.", usage = "sug <[messsage link|ID] | [phrase]>", aliases = ["find", "find-sug", "search", "search-sug"])
async def test_sug(self, ctx, search: Union[discord.Message, str]):
suggestions = self.bot.get_channel(id = self.suggestions)
if isinstance(search, discord.Message):
await ctx.reply(embed = search.embeds[0].copy(),) # components = """Needs a button linking to the message"""
else:
with ctx.typing():
matches = 0
output = " "
messages = await suggestions.history(limit = None, before = None, after = None, around = None, oldest_first = None).flatten()
for message in messages:
if search in message.embeds[0].title():
matches += 1
output = (output + f"[{message.embeds[0].title()}]({message.jump_url})")
embed = Embed(title = f"I found `{matches}` suggestions matching `{search}`.", description = output)
await ctx.reply(embed = embed)```
how do i set status for my bot
!d discord.Activity
class discord.Activity(**kwargs)```
Represents an activity in Discord.
This could be an activity such as streaming, playing, listening or watching.
For memory optimisation purposes, some activities are offered in slimmed down versions:
β’ [`Game`](https://discordpy.readthedocs.io/en/master/api.html#discord.Game "discord.Game")
β’ [`Streaming`](https://discordpy.readthedocs.io/en/master/api.html#discord.Streaming "discord.Streaming")
does anyone happen to have a discord mass group leave program?
I found an old one on github but its outdated and does not seem to work anymore because of a module that was used
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
!d discord.Activity
class discord.Activity(**kwargs)```
Represents an activity in Discord.
This could be an activity such as streaming, playing, listening or watching.
For memory optimisation purposes, some activities are offered in slimmed down versions:
β’ [`Game`](https://discordpy.readthedocs.io/en/master/api.html#discord.Game "discord.Game")
β’ [`Streaming`](https://discordpy.readthedocs.io/en/master/api.html#discord.Streaming "discord.Streaming")
How would I send backticks in an embed without them turning into code format
E?
!d discord.Activity
class discord.Activity(**kwargs)```
Represents an activity in Discord.
This could be an activity such as streaming, playing, listening or watching.
For memory optimisation purposes, some activities are offered in slimmed down versions:
β’ [`Game`](https://discordpy.readthedocs.io/en/master/api.html#discord.Game "discord.Game")
β’ [`Streaming`](https://discordpy.readthedocs.io/en/master/api.html#discord.Streaming "discord.Streaming")
Iβm confused
What is confusing
\ ```
how do i get the bot to edit it's message?
ctx.send returns a discord.Message object
?
So you can assign it to something
huh?
msg = await ctx.send("...")
msg will be a discord.Message object, which has an edit() method.
!d discord.Message.edit
await edit(content=..., embed=..., embeds=..., attachments=..., suppress=..., delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the message.
The content must be able to be transformed into a string via `str(content)`.
Changed in version 1.3: The `suppress` keyword-only parameter was added.
ok
so i would put smth like this?
@bot.command()
async def test(ctx, message=None):
await ctx.send('test 1')
await asyncio.sleep(1)
await edit(content=test 2)
no
@bot.command()
async def test(ctx, message=None):
msg = await ctx.send('test 1')
await asyncio.sleep(1)
await msg.edit(content="test 2")
thx
!pep8
PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.
More information:
β’ PEP 8 document
β’ Our PEP 8 song! :notes:
ERROR:cogs.error_handler:TypeError: '_EmptyEmbed' object is not callable (In test_sug)
Traceback:
File "/home/snowyjaguar/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/modmail/cogs/some_commands.py", line 24, in test_sug
if search in message.embeds[0].title():```how can I remedy this issue, my code is```py
@commands.command(description = "Lets users locate a specfic suggestion via it's message ID or link.", usage = "sug <[messsage link|ID] | [phrase]>", aliases = ["find", "find-sug", "search", "search-sug"])
async def test_sug(self, ctx, search: Union[discord.Message, str]):
suggestions = self.bot.get_channel(id = self.suggestions)
if isinstance(search, discord.Message):
await ctx.reply(embed = search.embeds[0].copy(),) # components = """Needs a button linking to the message"""
else:
with ctx.typing():
matches = 0
output = " "
messages = await suggestions.history(limit = None, before = None, after = None, around = None, oldest_first = None).flatten()
for message in messages:
if search in message.embeds[0].title():
matches += 1
output = (output + f"[{message.embeds[0].title()}]({message.jump_url})")
embed = Embed(title = f"I found `{matches}` suggestions matching `{search}`.", description = output)
await ctx.reply(embed = embed)```
Embed.title isn't a function
!d discord.Embed.title
The title of the embed. This can be set during initialisation.
okay thanks both
well now i'm getting this errorpy ERROR:cogs.error_handler:TypeError: argument of type '_EmptyEmbed' is not iterable (In test_sug) Traceback: File "/home/snowyjaguar/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped ret = await coro(*args, **kwargs) File "/home/modmail/cogs/some_commands.py", line 24, in test_sug if search in message.embeds[0].title:
the embed has no title
is there a way to get the bot to list the roles of a specified user?
iterate through a users roles using a for loop, use member.roles
there fore its not sending the same alert more than once
ok
hmm, odd because the embed defiantly has a title, or maybe it's the author field π€
!d discord.Member.roles
property roles: List[Role]```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [β@everyone](mailto:'%40everyone)β role.
These roles are sorted by their position in the role hierarchy.
okay so I figured out it's not the title field but the author field, how would I go about getting the author name? message.embeds[0].author.name isn't working so i don't think i'm doing it right
no, i'm trying to get the name in the embed author field
!d discord.Embed.author
property author: _EmbedAuthorProxy```
Returns an `EmbedProxy` denoting the author contents.
See [`set_author()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.set_author "discord.Embed.set_author") for possible values you can access.
If the attribute has no value then [`Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty") is returned.
so would i put _EmbedAuthorProxy in instead?
embeds[0].author.name should work as blanket said.
okay I got that working, but now I'm getting this errorpy ERROR:cogs.error_handler:IndexError: list index out of range (In test_sug) Traceback: File "/home/snowyjaguar/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped ret = await coro(*args, **kwargs) File "/home/modmail/cogs/some_commands.py", line 24, in test_sug if search in message.embeds[0].author.name:
@client.command()
async def hot(ctx):
coin=random.randint(1,2)
if coin=='2':
await ctx.send('https://thumbs.gfycat.com/GrimyBouncyDromaeosaur-size_restricted.gif')#tails
if coin=='1':
ctx.send('https://media.giphy.com/media/3oz8xAbE6jVnn6oorm/giphy.gif')#heads
!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.
Then the message has no embeds.
Add an else statement.
else:
print(coin)
async def hot(ctx):
coin=random.randint(1,2)
if coin=='2':
await ctx.send('https://thumbs.gfycat.com/GrimyBouncyDromaeosaur-size_restricted.gif')#tails
if coin=='1':
ctx.send('https://media.giphy.com/media/3oz8xAbE6jVnn6oorm/giphy.gif')#heads```
ok
Also, random.randint() returns an int.
And, it's await ctx.send(), not ctx.send().
so how would i do it
i want to use random int to represent the coin
1 being heads 2 being tails
random.randint returns an integer, what do you think you are doing wrong?
!e
print("1" == 1)
@dapper cobalt :white_check_mark: Your eval job has completed with return code 0.
False
'1' is not equal to 1.
ohhh
That's a string and that's an int.
i see
So i used message.created_at and it returned 00:54:02.169000 I was wondering how i could convert that to eastern time?
You can use the Discord markdown <t:timestamp> to make the timestamp show to everyone according to their local timezone.
!d discord.Message.created_at returns a datetime.datetime object which has a timestamp() method.
property created_at: datetime.datetime```
The messageβs creation time in UTC.
!d datetime.datetime
class datetime.datetime(year, month, day, hour=0, minute=0, second=0, microsecond=0, tzinfo=None, *, fold=0)```
The *year*, *month* and *day* arguments are required. *tzinfo* may be `None`, or an instance of a [`tzinfo`](https://docs.python.org/3.10/library/datetime.html#datetime.tzinfo "datetime.tzinfo") subclass. The remaining arguments must be integers in the following ranges...
Check if the current data is not equal to the new data then overwrite the current data with the new one.
!e
current_data = {"name": "Seif Wessam", "age": 15}
new_data = {"name": "Seif Wessam", "age": 16}
if (current_data != new_data):
for key in current_data.keys():
if current_data[key] != new_data[key]:
unequal_key = key
print(f"{unequal_key} is not the same!")
current_data = new_data
print(current_data)
@dapper cobalt :white_check_mark: Your eval job has completed with return code 0.
001 | age is not the same!
002 | {'name': 'Seif Wessam', 'age': 16}
whats wrong w this?
Is this in a cog?
in what?
A class?
await update.start()
Try that.
"await" allowed only within async functionPylance
it has the red squigly undernetah
add it under the on_ready event, but do something like wait_until_ready so the loop doesnt start before the bot is essentially ready
but i also dont think that is safe, since on_ready can be called multiple times.
wait wha, im confused this is the last def at the bottom of my code
why would i put that at the top
You can put the event anywhere, whether at the top or the bottom. It only matters if it's above the bot.run() and below the bot = commands.Bot() or not.
TypeError: updated() missing 1 required positional argument: 'ctx'```
still getting this error
async def on_ready():
await client.change_presence(status=discord.Status.dnd, activity=discord.Game("DM Me Commands!"))
print('Bot is ready.')
await updated.start()``` and this is where i put it
async def updated(ctx):``` and i need ctx in updated because the bot is sending a message
Oh, nope. Don't put ctx there.
but how is the bot supposed to dm me
What is ctx?
How does the loop has an author?
wut?
its a tasks.loop
Then it doesn't have an author. You will need to use bot.get_user().
!d discord.ext.commands.Bot.get_user
get_user(id, /)```
Returns a user with the given ID.
evan = client.get_user(your_id_here)
await evan.send("Hello")
Did you use a valid ID?
did you put it as an int or string
Does your bot have member intents enabled?
dunno what that is
!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.
!d discord.Intents.members
Whether guild member related events are enabled.
This corresponds to the following events...
intents = discord.Intents.all()
bot = commands.Bot(... intents = intents ...)```
be sure to enable intents on the dev app, under the bot tab.
because you didnt enable them.
Go to https://discord.com/developers/application/your_bot_id/bot and scroll down till you see "member intents" and enable them.
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
Show me where you defined client.
Did you define intents after defining client or before it?
before
if you use discord.Intents.all() theres no need for intents.members = Tue lol.
Try printing evan.
your ID returns NoneType, so the bot isnt finding you
be sure you put the right id.
as expected
Hold on, if it returns None and you have intents enabled, it's possibly trying to get your user before the bot has started, which means, you aren't in the bot's cache yet.
Try await client.fetch_user(your_id).
Instead of client.get_user().
correct.
fetch_user() will send an API request to fetch your user, which should work.
i think its a bit, uh, unnecessary to make an API call for that every minute.
!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.
^
@client.event
async def on_ready():
await client.wait_until_ready()
# start the loop
it works, but its so unnecessary
Do this and go back to evan = client.get_user().
Sending too many API requests might get you rate limited.
discords
oh shi
That's why the bot's cache exist.
Show your code.
What's there after await client.wait_until_ready()?
hello
get the user after the bot is ready
What's a good place to host my bot?
await client.wait_until_ready()
updated.start()
then just do global?
VPS
no, i was wrong sorry
you want to call it after.
i got myself mixed up
I suggest https://somehost.xyz & https://bot-hosting.net. I've personally tried both.
yep.
Yes.
Do you realize wait_until_ready fires when ready is set, which is also when on_ready is fired
ok sweet, thank you guys so much!
This does nothing
if you aren't making an api call every minute for that.
Question
Oh, does it?
Ah right, I didn't notice.
For these 2 VPS's. Do we have to run the code on our PC? Like i just want it all online like REPLIT
I upload my code and I run it there
Why would a hosting require from you to run the code on your PC? How is it a hosting then?
Yes, that's all you need to do.
then why do we have this? i thought we used this to encounter any issues like, things being loaded before the bots cache is ready.
Both of these hostings use Pterodactyl panel so it shouldn't be hard at all.
on_ready is already dispatched when cache is ready, wait_until_ready is used for things outside of on_ready
i guess it could be utilized outside of that, yeah
Doing outside of on_ready in this case is prefered anyhow
since you know, on_ready is dispatched multiple times
thus you will be starting a task over and over again
which is by no means good
right.
Yo how do I use that website? Everything I click links me to your server
My server?
You're a staff there
Oh yeah, but it's not mine.
So how do I use the website
Well, consider reading what the bot sent once you joined in the general channel. π
Heyy
It says daily points
So if I run out of points do I lose my server
No, it gets suspended. You can then open a ticket and ask the admins to temporarily un-suspend it for you so you can take your files if you would like to.
What about the free one
All servers cost coins, none are free.
Ohh On the website it says free..
Btw, we have a support channel. You can ask there instead of here as it's considered off-topic here. π
Free of real money, but we have our own currency.

@client.command(self= )
async def play(ctx, url : str):
voiceChannel = discord.utils.get(ctx.guild.voice_channels, name='βChill Lounge')
what am i supposed to put for self
what are you planning to do with it and whyd he give it to you
im planning nothing
teach him a lesson to not trust people that much
he have tons of bots he says
woah lets slow down a bit here
you can create as many bot applications you want to , not a big deal
does he want you to work on it for him or something i dont get why he just gave you a token
yes he wants me to work on it
but i have no idea
does he know how to work on it himself?
now
well do you know python?
i know
then go make a bot with it
Check channel topic for related links
i dont understand tho does he not know any programming language i dont get why he just handed the token to you
where?
im guessing you know python you just dont know much about discord.py?
yes
https://vcokltfre.dev in case you want some beginner knowledge about discord.py ( suggested not to watch yt tutorials)
okay got it
but what with token
thats basically a key
where to paste it or?
you would be using it in your code
import discord and async and put it in a token variable
in your py discord.Client.run() func
okay
thanks
i thought it was just client.run()
Bot = discord.Client()
Bot.run()```
Depends on how you define your variable
It's ultimately your discord.Client instance
Hey guys I need a second pair of eyes on this. Having no issues with the description embed. Only having issues with the return on the bot.get_channel not responding to a test message. Bot online. No errors present
u using replit?
Yes
Repeating test message to desired channel in bot.get_channel
so is the embed showing
Yes. The embed is working perfectly fine. The repeat is the issue
for the xsend command?
Yes
maybe the bot cannot get the channel , and since you have channel.send in if statement it's not raising the error
No errors present
Maybe fetch the guild then the channel? guild = bot.get_guild() then channel = guild.get_channel = ()
Ill remove it
π
This line is not present. Are you referring to "If channel"?
How does heroku work every month
It does not . For free
Wdym
removing "if channel" only creates a await channel.send(message) error
it runs free for just 20-23 days for free
My boy went down today and came back up without me doing anything
And it is around one month now of running it on heroku
Do you get this error py NoneType has no attribute send?
or something like this
When "if channel" is removed this is the error
so we can see it as a whole
^
BRO if u dont know what an unexpected indent is dont do discord bots yet
have u used a tutorial
!eval
e = 5
if e == 5:
print('e is 5')
@boreal ravine :x: Your eval job has completed with return code 1.
001 | File "<string>", line 3
002 | print('e is 5')
003 | ^
004 | IndentationError: expected an indented block
@fast hedge does it work now
The unexpected indent error was caused by removing if channel lol. I was testing his theory
@fast hedge already told ya to un-indent it
No. Like I said in the beginning the bot.get_channel repeast is not functioning. But there also no errors present
dude i think replit is different
so borax what do you type to trigger the embed to come
Why do you have channel id as a string? @fast hedge it will be an int
its an integer not a string
@fast hedge copy paste the code here so we can attempt to edit it instead of ss's
import discord
from discord.ext import commands
bot = commands.Bot(
command_prefix='.',
help_command=None,
)
@bot.event
async def on_ready():
print(f"online as {bot.user}")
@bot.event
async def on_message(msg):
await bot.process_commands(msg)
@bot.command()
async def stc(ctx, *, description='No desc provided'):
await ctx.send(embed=discord.Embed(description=description, colour=discord.Colour.red()))
@bot.command()
async def bto(ctx, *, description='No desc provided'):
await ctx.send(embed=discord.Embed(description=description, colour=discord.Colour.green()))
@bot.command()
async def xsend(ctx, *, message: str):
await ctx.message.delete()
channel = bot.get_channel("833449179840774184")
if channel :
await channel.send(message)
so i think instead of str write int bc the id is a int
Testing now
import discord
from discord.ext import commands
bot = commands.Bot(
command_prefix='.',
help_command=None,
)
@bot.event
async def on_ready():
print(f"online as {bot.user}")
@bot.event
async def on_message(msg):
await bot.process_commands(msg)
@bot.command()
async def stc(ctx, *, description='No desc provided'):
await ctx.send(embed=discord.Embed(description=description, colour=discord.Colour.red()))
@bot.command()
async def bto(ctx, *, description='No desc provided'):
await ctx.send(embed=discord.Embed(description=description, colour=discord.Colour.green()))
@bot.command()
async def xsend(ctx, *, message: int):
await ctx.message.delete()
channel = bot.get_channel("833449179840774184")
if channel :
await channel.send(message)
No change
Typing test in separate channel shows no results in ID channel
@commands.command()
it must be an int inside get_channel
Im just as confused
Where are you seeing id?
meaning the integer id(channel id) remove the "
That was an example , I mean the channel id you provide to get_channel
!d discord.Client.get_channel read it
get_channel(id, /)```
Returns a channel or thread with the given ID.
whats the command to see ur embed
borax have you done
client = discord.Client()
client.run(os.environ['TOKEN'])
token can be an environmental variable
They already sent the code , they use commands.Bot
the embeds are working perfectly fine
ss
light theme moment
Light theme mafia
ok and you used the code showed in https://hastebin.com/ebeketebab.py
Exact same
I only change int and the parentheses arounf the id
leme test on replit
On my replit the bot is online with no errors present. Weirdest shit
Not even an error when I try the test message
i just tried ur code and when i run, it stops running
strange
How do Ik how much Memory, Disk & CPU I need
import discord
from discord.ext import commands
bot = commands.Bot(
command_prefix='::',
help_command=None,
)
@bot.event
async def on_ready():
print(f"online as {bot.user}")
@bot.event
async def on_message(msg):
await bot.process_commands(msg)
@bot.command()
async def stc(ctx, *, description='No desc provided'):
await ctx.send(embed=discord.Embed(description=description, colour=discord.Colour.red()))
@bot.command()
async def bto(ctx, *, description='No desc provided'):
await ctx.send(embed=discord.Embed(description=description, colour=discord.Colour.green()))
@bot.command()
async def xsend(ctx, *, message: str):
await ctx.message.delete()
channel = bot.get_channel(879876032751087698)
if channel :
await channel.send(message)
``` so borax ur code is exactly this other than the change of channel id correct?
"str" changed to int per your request
doesnt work in my eyes
no, iirc you can have trailing commas
Hmmmm
You think you can help me with this? Cookie
This is my exact code. Obviously excluding my token https://hastebin.com/suyelohucu.py
im trying
Clearly , bot cannot acess the channel.
so strange
alr it works in my replit, i dont see ur problem borax
also how did u make ur thing .bto
@bot.command()
async def bto(ctx, *, description='No desc provided'):
await ctx.send(embed=discord.Embed(description=description, colour=discord.Colour.green()))
oh icc
It works perfectly fine in my replit as well. Did you test it in a discord channel?
Yes
why
And to repeat to the requested channel
so for eg?
?
borax i think it works fine
but do u know how to make it so that lets say if you say: oj it says orange juice is good or smthn in embed form, cuz if so, speak cuz that will tell me if replit is different
i want to make a command to disable other command
remove_command(name)```
Remove a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") from the internal list of commands.
This could also be used as a way to remove aliases.
i want to disable command only in that guild
Stupid question. Youre actually typing a test into a different channel and its repeating in requested channel through id?
And verify it in the check
You even used the embed command?
no for that part, it doesnt matter what i do it in
it will work regardless in the channel i send the command
How do I convert an emoji input eg
into the <:name:id> formart to insert into my db?
i think it thinks that the command works in the server that channel is in, i dont see another solution
sorry
does TextChannelConverter only look for 1 channel?
I think he means even if you dont fetch the channel and you do ctx.send() it'll send the message to the channel where u invoked the command.
hey can anyone help me with my blacklisting system for my bot? I want something like when i do *Blacklist (user) the user i tagged won't be able to use any command i'm using client btw
thanks edit: sorry for my english english is not my first language π
use bot check
\emoji
!d discord.Client.get_emoji or use this to get it using id
get_emoji(id, /)```
Returns an emoji with the given ID.
you would need a database to store user IDs , and a check which checks if the user is in database or not
!custom-checks
Custom Command Checks in discord.py
Often you may find the need to use checks that don't exist by default in discord.py. Fortunately, discord.py provides discord.ext.commands.check which allows you to create you own checks like this:
from discord.ext.commands import check, Context
def in_any_channel(*channels):
async def predicate(ctx: Context):
return ctx.channel.id in channels
return check(predicate)
This check is to check whether the invoked command is in a given set of channels. The inner function, named predicate here, is used to perform the actual check on the command, and check logic should go in this function. It must be an async function, and always provides a single commands.Context argument which you can use to create check logic. This check function should return a boolean value indicating whether the check passed (return True) or failed (return False).
The check can now be used like any other commands check as a decorator of a command, such as this:
@bot.command(name="ping")
@in_any_channel(728343273562701984)
async def ping(ctx: Context):
...
This would lock the ping command to only be used in the channel 728343273562701984. If this check function fails it will raise a CheckFailure exception, which can be handled in your error handler.
ok
can u help me with
actually nvm...
is it possible without a database?
just wondering...
technically yes but you shouldnt
why?
you can store the user in a list but thats temporary, if the bot crashes all the users in the list are gone
thats fine with me
Either use a db that you can update the list using commands or do it manually
You can , but it resets everytime you restart the bot
holy ooops
yeah that's fine
ok
hey when i make the list
do i use {} or []
what isnt
use a list
:>
obv [] lol
{} are for dictionaries
and sets
sorry new to discord.py
Hello, I am here to ask for help making a bot that shows info like in the picture below
!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.
!d discord.on_message
I was asking how do I make like a bot that shows a pie chart with role info and percentage on command.
they use some api , or numpy
read his message smh
Pillow?
hello guys i need a help regarding slash cmd with cogs i have made it without any error or so but when i go in discord and do / it is not showing me the cmd
which library?
error?
na likein discord its not showing me and slash cmd for bot leaving then in bulit cmds
like this mine bot slash cmd is not coming
!d discord.on_member_join
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.
Does the library support slash commands in cogs?
idk
check the docs/github maybe it isn't supported for cogs yet?
Are you using discord.py?
import os
import datetime
import asyncio
from discord.ext import commands
from discord_slash import cog_ext
class Mod(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
@commands.cooldown(1, 5, commands.BucketType.guild)
async def ping(self, ctx):
embed = discord.Embed(title=f"πPong! {round(self.bot.latency * 1000)}ms", colour=discord.Colour.blue(), timestamp=datetime.datetime.utcnow())
await ctx.reply(embed=embed)
@cog_ext.cog_slash(name = 'Ping', description='Sends Ping')
async def ping(ctx):
await ctx.send('pong')```
yea
idk i saw a yt video and got from there
In the video did he do it in a cog?
yea
then it work work?
In this video we are creating slash commands with the discord.py library and the slash commands library. I'll show you how to do this with and without cogs. This isn't too long either it's only 5 minutes!
Slash commands are a great way to elevate your python discord bot to the next level so make sure to watch.
What are slash commands: https://...
what lib tho
3:40 time
ok
:))
u forgot self?
yes I am talking about with Numpy
oh
and role member number/percentage
!pypi dislash.py better use something like this
How do I check if message.content has a user ID?
well ,any 18 digit long number can be a userid
Actually thats a really good idea
to check it just see if get_user(16_digit) is not None
if any(bool(bot.get_user(_id)) for _id in message.content.split() if _id.isdigit()):
... # the message contains valid id
can anyone help me outhere?
emed
Thank you but how would I get the ID?