#discord-bots
1 messages · Page 756 of 1
What should I start with?
Discord.py
Nextcord
Py-cord
Hikari
just use disnake
or any fork
which ever you would like
disnake is a fork its just dpy but better
expect discord.py as it isn't maintained anymore
Thanks
Disnake isn't very different tbh
its a fork of dpy ofc it wont
only different things are the new features
which arent hard to learn
So should I unistall discord.py first
exactly, so they won't need to start over.
yeah
If u dont wanna use the shim, it's fine, no need
Shim ?
Shim?
Yea
All the namespaces are named discord
So instead of disnake imports, u can do discord imports
import disnake as discord
Someone has Fivem status bot with player list that do not has crashes?
bad practice tho
Its really not that big of a deal refactoring your code from discord to disnake
just change the word discord to disnake
Ctrl h 
can someone help me with coloring text the bot sends in discord? I just can't get it to work.
What else should I remove for disnake
prolly discord
are you talking about the new ANSI codeblock feature?
Sure
what is the problem?
that's not ANSI, that's just syntax highlighting
regardless, the issue is that you're not starting a new line after diff
Add \n after diff proly

can you send an example of a bit of python code that colors the message my bot sends?
If you want it to be colored with Python highlighting, you can create some sort of pagination and clean code function
await ctx.send("diff\n + I'm green\n - I'm red")
?
this is what I got from this
Yea wait lemme try
Oh nice
is it because I didn't give the bot a specific permission or something when I added it??
Virtual Environments
Virtual environments are isolated Python environments, which make it easier to keep your system clean and manage dependencies. By default, when activated, only libraries and scripts installed in the virtual environment are accessible, preventing cross-project dependency conflicts, and allowing easy isolation of requirements.
To create a new virtual environment, you can use the standard library venv module: python3 -m venv .venv (replace python3 with python or py on Windows)
Then, to activate the new virtual environment:
Windows (PowerShell): .venv\Scripts\Activate.ps1
or (Command Prompt): .venv\Scripts\activate.bat
MacOS / Linux (Bash): source .venv/bin/activate
Packages can then be installed to the virtual environment using pip, as normal.
For more information, take a read of the documentation. If you run code through your editor, check its documentation on how to make it use your virtual environment. For example, see the VSCode or PyCharm docs.
Tools such as poetry and pipenv can manage the creation of virtual environments as well as project dependencies, making packaging and installing your project easier.
Note: When using Windows PowerShell, you may need to change the execution policy first. This is only required once:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Yea I did it
please 😭
It's not because of perms
so whats the issue o.o;
i'm not sure myself.. you could try a multiline string
@slate swan look at the msg above this😉

pogggg
Back at purchasing a software I go 
gl

yo can someone help
@bot.event
async def on_member_update(before: discord.Member, after: discord.Member):
guild = after.guild
role = guild.get_role('932629790878482522')
activity_string = after.member.activity.name
string_to_check = ". gg / void"
if string_to_check in activity_string:
await before.add_roles(role)
.
is this throwing an error?
no
it just doesn’t works
do you have privileged intents?
i enabled everything
no i didn’t add intents
lemme try that
What is wrong with this?
import disnake
import mytoken
from disnake.ext import commands
bot = commands.Bot(command_prefix=".")
token = mytoken.TOKEN
bot.event
async def on_ready():
await print("Bot is ready")
bot.command()
async def color(ctx):
await ctx.send("just a test")
bot.run(token)
indentation?
oh wait, nvm
Why r u awaiting print
K
💀
read the message.
i did
it says right there how to fix
open the developer panel and enable the privileged intents
i did enable it
are you sure it was the correct application?
yh
O lol
Lmfao
kk
@bot.event
async def on_member_update(before: discord.Member, after: discord.Member):
guild = after.guild
role = guild.get_role('932629790878482522')
activity_string = after.before.activity.name
string_to_check = ". gg / void"
if string_to_check in activity_string:
await before.add_roles(role)
no errors but it doesn’t work
Do you have member intents?
Do you have them enabled in code and the developer portal?
yh
And did you pass them in to your bot constructor
yh
intents = discord.Intents.all()
bot = commands.Bot(command_prefix=prefix, intents=intents)
How do I add slash commands to my bot
Don't use camelCase
Use a lib that supports them. I would suggest you use disnake
could anybody provide an example for code to a colored message being sent by a bot?
Colored message?
yea like ```md
#helo
Discord is now slowly rolling out the ability to send colored messages within code blocks
Not sure but that might mean only certain users can use it?
Or I'm just an idiot
I dunno
it seems to work for other people, I got a friend who says that their friend has got it working
wdym```
D;
Discord has always had the ability to send coloured messages via codeblocks
It's just getting more POWERFUL since discord is rolling out support to ANSI highlighting
Which is basically just colours
so whats my issue o.o
Ah
So thats the difference
I know code blocks had been around awhile
@weary mirage
Try this
@bot.command()
async def color(ctx):
await ctx.send("^^^py\nlol = op\nimport\n#discord\n^^^")
#Instead of ^ use `
These are my results
K
okay so, how would I change the color of it now
@bot.command()
async def colortest(ctx):
await ctx.send("diff\n+ I'm green\n- I'm red\n")
And yea add `
for the bot I'm making, I'm trying to have it so one of the bits is blue
just like a number that's colored
is there a way to have the text colored blue?
Idk
[blue text]
with a python bot :P
can I have a bit of text that's blue within a big string of text?
.bm
@client.command()
async def userinfo(ctx, member: disnake.Member):
if member.mention == 'SkilledYoshi#777':
return
else:
embed = disnake.Embed(
title="USER INFO",
description=f"Here is the info we retrieved about {member}",
colour=0xD7DCF6)
embed.set_thumbnail(url=member.avatar.url)
embed.add_field(name="NAME", value=member.name, inline=True)
embed.add_field(name="NICKNAME", value=member.nick, inline=True)
embed.add_field(name="ID", value=member.id, inline=True)
embed.add_field(name="TOP ROLE", value=member.top_role.name, inline=True)
await ctx.send(embed=embed)```
it doesnt return
when i mention the member
it just sends the embed
!d discord.Message
class discord.Message```
Represents a message from Discord.
x == y Checks if two messages are equal.
x != y Checks if two messages are not equal.
hash(x) Returns the message’s hash.
Can you check if a member was mentioned like that?
for me?
A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.
Warning
The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.
Try with this
I dont want a list of users mentioned
Why not just check if the member's id is the same as the id you want?
i want a special embed for a specific person
Compare member.id with the id not the mention
So then check the id
do is just do
client.get.userid
and
if user is true
user = client.getuserid(e22168618723)
No?

im crazy dw
property id```
Equivalent to [`User.id`](https://docs.disnake.dev/en/latest/api.html#disnake.User.id "disnake.User.id")
Then compare it to the id you want
if member.id == 735757517765869589```
cool no quoations on the numbers?
It's int
Not a string
You could just, Union discord.Member and discord.User, then isinstance
Discord.py's converters support this
ah yup thanks
Guys, I just watched a tutorial and it said to do client = discord.Client() at the start but its not working it says "discord" is not definedPylance.
Any idea? I have never made a dc bot before so i can't say
Did you install the pypi?
Whats that? xd
You shouldn't be watching that tutorial
Its objectively bad
!pypi disnake
How so?
If he only wants events it's actually all he/she needs.
If you're using an if message.content... system you're missing out on a lot of resources
I'm assuming that the person asking the questions actually knows what their own code is/does
Yeah
They did say that they had never made a discord bot before
Still get the same thing
They're most likely unaware of actual commands
Do you want to use disnake, nextcord or discord.py?
Suggested lib is from left to right.
I really don't know as I am a complete beginner trying to do a basic thing since its my first time
Then take the most recommended one
disnake
So do global checks not apply to slash commands?
What does it do?
It's the most preferred fork of discord.py
It does everything discord.py can do and more
!d disnake.ext.commands.Bot.slash_command_check slash has their own stuff.
slash_command_check(func)```
Similar to [`check()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Bot.check "disnake.ext.commands.Bot.check") but for slash commands.
And whats discord.py do?
Thank you
Its a wrapper for the discord api
#777? Ig u forgot to add another 7 and ig u need to add @ aswell idk
Basically they are a wrapper of the bare API so you (and me) don't have to think too much.
yeah i thought too but yea didnt work
Then idk😭
@slate swan mentions will always return a string @slate swan
Ye.
Better to use the id.
Is there a good video that I can watch to just get a bot running and have a simple command with it that also teaches me some of this stuff?
True
I could code a simple bot.
can someone help me out in #help-kiwi the person helping couldn't figure it out so i was hoping someone in here could help.
https://github.com/DisnakeDev/disnake/tree/master/examples
These also provide a lot of examples
I'm not aware of any videos but this website is pretty good
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
They're using discord.py but you're using disnake therefore where ever they use discord you should use disnake
event works and all, but I always get this error and I want to handle it
discord.utils.get(message.guild.channels, id=928014494142197820)
AttributeError: 'NoneType' object has no attribute 'channels'
thanks
Could you maby show the whole event?
one sec
Do you have a real simple one you can show me?
There are some examples with that link i sended -> https://github.com/DisnakeDev/disnake/blob/master/examples/basic_bot.py
Ok thanks
import disnake
from disnake.ext import commands
bot = commands.Bot(command_prefix="")
@bot.event
async def on_ready():
print("ready")
@bot.command()
async def hello(ctx):
await ctx.send("hello")
bot.run("token_goes_here")
👀
👀
👀
@bot.event vs @bot.listen()
listen is better but i like using event on ready for a reason
ruby vs python on ready
bot.ready do
puts "ready"
end
@bot.event
async def on_ready():
print("ready")
python
no
this is my bot ```py
from discord.ext import commands
import os
import discord
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix=".")
bot.load_extension("funcommands")
bot.load_extension("moderation")
bot.load_extension("errorhandler")
bot.load_extension("usefulcommands")
@bot.event
async def on_ready():
print("All resources loaded and bot is now running!")
bot.run(os.getenv("TOKEN"))```
for loop for cogs smh
what
use a for loop to load all cogs
intents is defined but not passed.
that to
for filename in os.listdir("directory of cog folder/cog"):
if filename.endswith("py"):
self.load_extension(f"cogs.{filename[:-3]}")
No
yes
Very bad practice
import importlib
import inspect
import pkgutil
from typing import Iterator, NoReturn
import exts
def unqualify(name: str) -> str:
"""Return an unqualified name given a qualified module/package `name`."""
return name.rsplit(".", maxsplit=1)[-1]
def walk_extensions() -> Iterator[str]:
"""Yield extension names from the bot.exts subpackage."""
def on_error(name: str) -> NoReturn:
raise ImportError(name=name) # pragma: no cover
for module in pkgutil.walk_packages(exts.__path__, f"{exts.__name__}.", onerror=on_error):
if unqualify(module.name).startswith("_"):
# Ignore module/package names starting with an underscore.
continue
if module.ispkg:
imported = importlib.import_module(module.name)
if not inspect.isfunction(getattr(imported, "setup", None)):
# If it lacks a setup function, it's not an extension.
continue
yield module.name
EXTENSIONS = frozenset(walk_extensions())
def load_extensions(self) -> None:
"""Load all enabled extensions."""
logger.info(f"Loading extensions")
# Must be done here to avoid a circular import.
from utils.extensions import EXTENSIONS
self.bot_extensions = set(EXTENSIONS) # Create a mutable copy.
for extension in self.bot_extensions:
logger.debug(f"Loading extension {extension}")
self.load_extension(extension)
better

[BETA] https://guide.disnake.dev
.bm
Oh yeah alec's new site :3
i feel like i have seen this somewhere LMAO
How can I tell when someone mentions me? @tawdry wind
OoOoO
looks good ngl
kinda, it's more or less being written by disnake maintainers at this point. I think he's resurrecting his guide as well
Don't improve it if it works y know
okimii's for loop had flaws
lmao
I improved it 🥲
no it didnt
I does
hii
I then de-improved it when adding it to another bot
its just looping through all files
One init file in there and it breaks.
The website doesn't look finished
It will also import non cogs
the guide is 100% not finished
Yeah I noticed
the beta tag is extremely important
if not filename.startswith("_") and filename.endswith("py"):
``` and just put it in a cog file like most people do
What if i would make a folder in that folder and have cogs in there?
Just make another for loop?
look through that dir
🤦♂️
for filename in os.listdir("C:/Users/okimii/Downloads/mainfolder/subfolder"):
is what you mean?
no nested cogs
who would nest cogs
thats what i sent
Beat having cog files with over 500 lines
you dont need the C:/blahashhsa
i have to cuz my os cant find anything then
You debugging in your IDE?
no
some people have file structures like this in terms of cogs
src
|-> cogs
|-> moderation
|-> cog.py
|-> help
|-> cog.py
cringe but ye
This is not a good example
This is what i mean -> https://github.com/python-discord/bot/tree/main/bot/exts
What I want to do:
check if a user has my vanity in their status
role them a special role if they do
if they remove it, it removes their role
if they changed their status and it was not my vanity, ignore
questions:
what event do I use? I used both on_member_update(before, after) and on_presence_update(before, after), none of them worked
mine
├───banker
├────cogs
└───__cog.py__
property status: disnake.enums.Status```
The member’s overall status. If the value is unknown, then it will be a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") instead.
no thats tideous
I was joking, compare the before and after.
here's what I wrote
@bot.event
async def on_member_update(before, after):
guild = bot.get_guild(914533133179813919)
role = discord.utils.get(guild.roles, id=931191386076749896)
if before.activity != after.activity:
if after.activity in ["v1", "v2", "v3"]:
vanity_embed = Embed(description=f"{after.mention} thx 4 repping **vanity** ", color=0x0f0f0f)
channel = bot.get_channel(931191146099658822)
await after.add_roles(role, reason="Repping Vanity")
await channel.send(embed=vanity_embed)
try:
await after.send("appreciate it for repping **vanity**. you were given the vanity role")
except discord.Forbidden:
pass
else:
if role in after.roles:
await after.remove_roles(role, reason="removed vanity")
hi amiri lol
mb
lolol
Mina could i ask something of you :3
sure
REACTIONS😠
Could you maby take a look at this -> https://discordapp.com/channels/267624335836053506/429409067623251969/932660921929711637
lol nah
😔🚶
i did see that, but don't have the knowledge to determine whether to pin or not
i'd bring it up again in a few days?
Oh okay, not too familiar with the process thanks for clarifying.
me neither lol, i don't think there's any formal process for requesting pins, so what you're doing i think is fine
i have a ? for you though
did you see my earlier ping?
Sure
it was a ? about tos for the code that was generating a guild invite
is it actually tos breaking ?
it was several hours ago
Let me check the code that we are talking about one sec
Got it, as far as i know it does not break ToS. But i did not imply that, i told him that it isn't appropriate to ask this since it has some privacy concerns for me. I also did not say that other people can't answer this.
Reading it back he can grab any ID he wants to.
grab any what ID?
"grab that guild", no, you can't do that with a bot
why wouldn't you be able to?
i mean, if we refer to the guild id yes, but if we talk about grabbing the guild like new owner, no lmao
can we speak on more higher level terms
yes ofc you can get a guild obj
bc idk anything about dpy
what is the code attempting to do and why may it not be respecting privacy?
he wants the bot to create a invite for private guilds
Let me rephrase, he told me he can get any guild.id he wants to in what guild his bot is in.
I told him he can't but he can, i just didn't fell comfortable helping him since he can just create invites for other servers without them knowing it.
yeah
and where was the invite being sent?
to himself i suppose
mk
or to a private channel in a different guild
return await ctx.author.send(invite) to the user who entered the command.
hes just making unauthorized invites for himself
hard to say it is 100% unauthorized
well, i wouldn;t day unauthorized, since you invite a bot with certain perms you assume
Not exactly it is authorized since they accepted his terms of the bot when inviting but for me it's inappropriate either way.
yeah
making a invite without people knowing isnt quite correct what if they get raided because of him?
leaking an invite
His ToS explicitly says he can make invites to the guilds?
i mean yeah your correct but its not approved by the owner or staff
they might not know about it, sure. but that is on them
that's pretty stupid doe, getting fired up over bullshit, in most of the servers anyone can create invites and no one need to get the approval of owners or shit
Well no but if the person that invites the bot gives access to create_invite.
so how do bot owners dictate their terms for using their bot?
yeah but he said its a private server
does discord developer portal allow bot devs to write their own terms?
They don't have to, Discord moderates that and the servers administrators.
or it's written externally somewhere?
no they dont but when adding a bot you will see all the perms it will need
so if you accept it will give that bot all those perms
so discord bot owners never add their own conditions or stipulations?
i mean, i'm sure they do
you can on git
well, depends what we understand by private, because according to discord, any server that is not in discovery is private, or private by the fact that no one is able to create invites and just certain people join in
but i guess they'll write them elsewhere
yeah
yeah but like panda said you accepted that the bot takes all those perms
kinda ethically wrong tbh
There is a lot to it.
^
Not if the user has denied the permission to the integration account. And yea making invites as a bot without owners permission is against the ToS apparently from what I've heard. If the bot does not have this defined explicitly in their privacy terms then /shrug
Most often done
hehe /shrug
source to this info where tos saying you can't make invites as a bot if unauthorized, just curious because didn't heard of it
When creating a Discord account you also accept the usage of bots, that they can read your messages, see join date, id, activity, avatar, reactions, when profile updates, how active the user is... etc.
I'm not sure of exact part but overall the discord ToS also includes that if you break some other services ToS via the API that is against ToS. Therefor, if someone's guild has a ToS like that it would be deemed against Tos
that is true as discord said if you break a platforms tos you are breaking theres
sure, i'm just wondering if a bot dev can stipulate their own additional terms, such as "if you use my bot i can create invites and invite members as i wish"
why wouldn't he
"... and relay them to myself"
i mean most bot devs do have their own tos for their bot
The invites stuff would also fall under this scope of the ToS, so yea....
that's about PII. idk if relevant here ^
That would be the formal way to address it. But again the user already accepted when creating a Discord account.
Read under
mm
well, invites are not personal information
There is a wholeee other section on griefing as well..
Again read under lol
it still specifically says "user information"
yeah i did, irrelevant to the topic
invites are not user info 
Are guilds not personal information?
how are they
Invites directly correlates to that
I think guilds can be personal.
I know what song you listed to, what was that loll
"37 dicks" my favorite
Ah s3rl now it makes sense
ofc you can see just the mutual guilds, but again this is not quite personal information the paragraph is talking about, it's just stupid at this point
@daring olive I hoped that answered your question :3
I also recommend coding a Discord bot, it can be a small one :)
You'd be surprised how much info bots can get with the right coder..
i kind of only have more questions now, but that's okay lol
I'm still here for the next 2 hours :3
Welp, doesn't matter if it's personal information in the case of the invites, if what you said was true as discord also has another thing in their policy
Again, going back to the, EXPLICIT definition of invite making
"surprises" lmao
If I was an owner of a guild and my guild was suddenly opened to the bot's owner because of this
Roulette command:
I'd be surprise!
😂
Could also, like I said earlier violate a guilds ToS
Also maybe a privacy policy?
If you look hard enough even /ping violates ToS Andy
how would i do command aliases?
Wouldn't be surprised
inside the command decorator
@bot.command(aliases=['alias_here'])
I would
Laws can be interpreted in many ways, along with terms
Yep...
can someone try help me in #help-cherries i have some kind of db issue with my bot but no one has been able to fix it
Exactly
cc @daring olive they do
and as of a few days ago, discord now requires users who submit for verification to provide a link to a privacy policy AND a terms of service link.
anyone know how to use replit db that can help?
it's not good to use in a bot
Replit in general is bad
yeah, hosting services aren't that expensive
Replit's "db" is just a persistent dict right?
pretty sure idk
it makes requests
yep it is
Requests 👁️ 👁️
Replit Database is a simple, user-friendly key-value store inside of every repl. No configuration is required; you can get started right away!
For some reason to me that feels somewhat insecure
I find relational databases much more powerful due to the SQL langauge
Key-value databases are amazing in their own terms, but not as power as relational databases
Traceback (most recent call last):
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\thoma\Desktop\discord.py\python\main.py", line 84, in on_raw_reaction_add
with open('reactrole.json') as react_file:
FileNotFoundError: [Errno 2] No such file or directory: 'reactrole.json'
async def on_raw_reaction_add(payload):
if payload.member.bot:
pass
else:
with open('C:\Users\thoma\Desktop\discord.py\python\reactrole.json') as react_file:
data = json.load(react_file)
for key, value in data.items():
emoji = payload.emoji
role = discord.utils.get(client.get_guild(payload.guild_id).roles, id=829665222380879912)
await payload.member.add_roles(role)```
with open("C:\Users\thoma\Desktop\discord.py\python\reactrole.json") as react_file:
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape```
change your back slashes to forward slashes
ok that worked
This is my code ```py
@slash_command(name="writecode", description="Writes a code snippet using a prompt", options=[SlashOption(str, name="selection", description="First argument", choices=[
create_choice("First Choice","first"), create_choice("Second Choice", "second")
], required=True), SlashOption(str, name="written", description="Second argument", required=True)
])
async def mySlashCommand(ctx, selection, written):
print(f"Selection: {selection}")
print(f"Written argument: {written}")
And it results in this error
```TypeError: myCogs.mySlashCommand() got multiple values for argument 'selection'```
I'm using the discord_ui module. Does anyone know what the problem might be?
is there any way i could get an argument without order
for example i wanna get a value for width without providing height
is there a way to do smthing like .cmd widht=200
and when i wanna provide height .cmd height=200
is there a way to accomplish this?
for file in os.listdir():
if file.endswith('.png') or file.endswith('.mp4') or file.endswith('.jpg') or file.endswith('.jpeg'):
files.append(file)
random_ = random.randrange(len(files))
await ctx.send(files[random_])``` anyone know whats wrong with this
Is it giving an error?
What are you expecting to happen?
i want it to append all the image links and then when someone says .image it will post it at random
then it would be .choice
then ctx.send(random.choice(files)) is probably what you want
ah alright ill try it
radrange gives a range of ints
so ```py
return await ctx.send(file=disnake.File(f'./path_to_file/{random.choice([file for file in os.listdir() if file[-4:] in [".png", ".gif", ".mp4"]])}'))
Still gotta send a File object.
u think it'd be good to ompress it like that?
What level of coding?
you're in my bots repo
i love list comprehensions
Why wouldn't it be?
Send 😅
quick question 4 how many years have u been coding
ah
panda having a stroke
thats nothing compared to what he does with regex
its scary what he can do with regex
filter(lambda f: f[-4:] in {".png", ".gif", ".mp4"}, os.listdir())
andy the goat
sent
9 months now
this work 4 the most part but when checking the file extention it doesn't 😅
thats cap
Actually does os.listdir() even show extensions
!e import os; print(os.listdir())
@pliant gulch :white_check_mark: Your eval job has completed with return code 0.
['Pipfile.lock', 'Pipfile', 'config', 'snekbox', 'user_base', 'tests', 'LICENSE']
in early years compressing looks pretty cool but with compressing u have to maintain readability
Ok tested on my own it does kek
Bout to say
That's completely possible.
Dunno what do you like to add?
list comprehensions are easy to read
I dont know, i need ideas as to what to add
Files under 500 lines is a start
all my files are over 500 lines 
Seesh that is a huge gap
The Syntax Of List Comprehensions
newlist = [expression for item in iterable if condition == True]
I know filter is faster i also did this test couple months back.
The syntax of list comp is weird though so sometimes it's not always like that
yeah i mostly go by this tho
Yeah if you for example have a double or triple for loop in it, it can get pretty messy
I had that issue with my wrapper's dispatch function yesterday
can you show how it would look like
lst = [(j, k) for j in s1 for k in s2]
ah ic looks good
[[item.check(*payload) for item in data] for data in zip(*[self.listeners[event], self.once[event]])]
oh yeah ive seen that way as well
lst = [
j + k
for j in s1
for k in s2
]
[a for b in a for b in a for b in a for b in a for b in a]
dunno if that even works lol
panda🧍♂️
@cloud dawn26 files, 10k lines
Uhh this would just make a 2D array
With whatever A is
from a quick glance
!e ```py
a = list(range(10))
print([a for b in a for b in a for b in a for b in a for b in a])
@cloud dawn :x: Your eval job has completed with return code 143 (SIGTERM).
[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1,
... (truncated - too long)
Full output: too long to upload
called it
files = [file for file in Path('.').iterdir() if file.root in ('png', 'mp4', 'jpg', 'jpeg')]
await ctx.send(random.choice(files))
hi does anybody know how i can make my bot only send a message when only something changes
ranodm
Random indeed
What is "something"
!d discord.ext.commands.FlagConverter
class discord.ext.commands.FlagConverter```
A converter that allows for a user-friendly flag syntax.
The flags are defined using [**PEP 526**](https://www.python.org/dev/peps/pep-0526) type annotations similar to the [`dataclasses`](https://docs.python.org/3/library/dataclasses.html#module-dataclasses "(in Python v3.9)") Python module. For more information on how this converter works, check the appropriate [documentation](https://discordpy.readthedocs.io/en/master/ext/commands/commands.html#ext-commands-flag-converter).
iter(x) Returns an iterator of `(flag_name, flag_value)` pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.
New in version 2.0.
a variable
cant you do
await ctx.send(random.choice([file for file in Path('.').iterdir() if file.root in ('png', 'mp4', 'jpg', 'jpeg')]))
im making a bot to track whenever somebody logs off hypixel on minecraft
don't
why not
multiple or too much layers of abstraction sacrifices comprehension
¯_(ツ)_/¯
so when u do files = reader knows that this variable contains a bunch of filenames
ik
aannd ur future will hate you less 😂
@pliant gulch I'm starting to like java now
Readable true, but also less preform-ant because you need to init a new variable that you never use again
my feature self rn: 🏃
eww
Java is dead
ruby is where its at
c# > java
C++ > C#
this the full image lol
c > c++
True
binary > c
but knowing me I'll forget to free heap memory
it goes to garbage collection ryt after funtion ends
so no prob
And you would need resources for the garbage collector!
It's not like the garbage collector runs without any computing power
its just overused tbh
overrated lang
but kotlin is kinda replacing it
Good
python is just this
class Python < Ruby
def initialize
puts "new language"
end
Kinda wanna finish my compiled programming langauge but I am now committed to working on my wrapper
😔
u'd need a lot more unused variables like that to even consider optimising it
if u don't like having unused variables good luck bro 😂
I also zip my python files for better performance
not really cuz python is older than ruby
How does that matter in this case, you send a computed value, done. Second you'd compute a value, initialise a new variable send it, then wait for the garbage collector to free the memory
it would make sense in a 1950 computer tho
u r talking abt memory optimising
that's how it matters
u need thousands of memory heavy classes to not make variables
And your saying rather than optimising one thing it would be better to have more things like that before even thinking about optimising
You don't need to write sloppy code everywhere 😂
first of all, u've seen big code bases?
Yes
they have a reason to use is_connected = True; if is_connected code like this ryt?
is_connected better defines wht we r doing
variables have the naming power that absoulute values never had
If is_connected is used more than once
Otherwise there would be quite literally no point
agreed
Your failing to realise that big code bases most often have groups of people working together via other forms of communication
Telepathy
Big code bases also often tend to have their own coding styles, rules etc
so?
Contributors already know whats going at what part of code they are looking at
If they don't ask the person who coded it, or someone who does know
that's the glory of communication
there u go u gave ur own answer
I don't need to make a pointless variable to tell everyone that this is a bool that represents a connection is there
If a big codebase is making horrible code like that, I'd would be thoughtfully disappointing
A coding rule that you have to do badly optimised code!
sometimes when the complexity increases u want to but most of the time u can avoid it
and it solely depends on opinions
If your making a one time variable for code complexity I'm not sure what's wrong with you
If you space out your code, write comments, docstrings, annotations
It will literally be readable as ever
if someone can understand what it means and it's thier codebase he can do whatever he wants
not all cases
I don't think big tech can afford to make badly optimised code
🤔
Not scalable and will cost them hundreds
Especially at the point where most of the worlds water is used for water-cooling at datacenters
k whtever u don't have to make variables if u dont want to 😂
Which as actually a bad thing.
Never said I don't want to not make variables, I said what's the point of one time variables
Lmao

Yep, super bad
bro wht i meant is it's totally ur opinion, if u want to do it if u don't want to, don't do it
how does one use params in slash commands?
Daily data centers in the US spend about 1.7billion litres of water
wow...
how the heck you know that
News
?
Articles
i get trash news
bro at that scale that single variable would surely cost millions
like any params?
I don't think big tech can afford to make badly optimised code
I see the message i was searching :3
Here are some examples -> https://github.com/DisnakeDev/disnake/blob/master/examples/slash_commands/param.py
ty
this is just a program running in our daily computers
VS
nvm then
!ytdl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
correct
indeed
BRUHHHHHHHHH
Were you not here when big bots got DMCA'd by google
@commands.slash_command(name="avatar", description="gets a users avatar")
async def get_avatar(
self, inter: ApplicationCommandInteraction, member: disnake.Member = None
):
if not member:
member = inter.author
em = disnake.Embed(color=0xD3D3D3, title=f"{member}'s avatar")
em.set_image(url=member.avatar.url)
await inter.send(embed=em, ephemeral=True)
this code look correct?
Yup
just set the var as the author or the member
?
member = member or inter.author
will it continue to happen?
or is it finished
if the member is none it will be the interaction author
Yes it would work, they are just jealous of the code.
yeah that's good
i do that on a daily
but ok
@cloud dawn Could you please help me with this now?
and you can do
em = disnake.Embed(color=0xD3D3D3, title=f"{member}'s avatar").set_image(url=member.avatar.url)
Who knows but it def could happen again ¯_(ツ)_/¯
Why wouldn't it
eh i don't recommend this
doesnt matter
:3 it worked as it was
nothing bad with it yes if its to long it wont follow pep 8 but who cares
thanks :3
looks better imo
How does this break pep8
pretty pep8 valid :3
if something is too long it wont follow pep8 i forgot the limit
correct
This line of code seems to be
Yeah just re-throw the question here.
maybe 95 or 90ish long?
to lazy to count
!e print(len("em = disnake.Embed(color=0xD3D3D3, title=f'{member}'s avatar').set_image(url=member.avatar.url)"))
@slate swan :white_check_mark: Your eval job has completed with return code 0.
95
async def randgame(ctx, arg1, arg2):
randgam = random.randrange(arg1)
if arg2 == randgam:
await ctx.send("congradulations")
if arg2 != randgam:
await ctx.send("Wrong try again")``` I am trying to create a number game where the user has to guess the number but it is saying Command raised an exception: ValueError: non-integer arg 1 for randrange()
type hint it to a int
What are some ideas I should do with slash command implementation
I wanna implement them to my wrapper in a clean way
by clean wdym
Disnake is pretty solid
ApplicationCommandInteraction except for this stupid long ass name
Simple, sleek
mhmmmm
Not too sleek otherwise we will just have another discord arch
What does that mean
Means that if you do it too bare people might not understand it easily.
yeah
no def no
Aw fuck, I'm gonna probably have heavily use metaclasses to keep everything large behind the scenes and keep the interface itself clean
😔
I dabble with metaclasses tho
lol
let's all use js
ruby is less supported than Python
Tbh I don't even need to prefix App, since rin is purest and there is no "vanilla" commands extension
We are not going to evolve backwards.
"nope. My bot is spamming me with "@hard trail, you aren't allowed to say that!" every 5 seconds"
Purest in a way where it only uses what the API gives
yeah
I meant to code :3
As a minimalist I can say that is never true for me
As long as people are coding on x86 things will never be minimal.
bot.command hi do |event|
event.send "hello"
end
how is this bare

Disgusting
ew
Why is the function body like that
i dont know you guys anymore🧍♂️
async def on_message(ctx):
for word in naughty_words:
if word in ctx.content:
if ctx.author.guild_permissions.manage_messages:
...
return
if ctx.author == bot.user:
...
else:
await asyncio.sleep(3)
await ctx.delete()
await ctx.channel.send(f"{ctx.author.mention}, you aren't allowed to say that!")
await bot.process_commands(ctx)```
This send is like python 2 all over again
smh man🚶
its beautiful yall just dont know whats real beauty 😔
What is ctx.content?
Ew
It's so weird
you as well🚶
yall talk allot about ruby smh when you guys be programing in rust🏃
I literally use assembly smh
That's the part of the code you gave me
wut
But it didn't work
What
you do what
ew
rust is fire
🏃
ayo
rust > ruby
ain no way he just said ruby over rust
I haven't used rust
i did
💀
yeah, gotta close discord after that one 💀
@bot.event
async def on_message(ctx):
for word in naughty_words:
if word in ctx.content:
if ctx.author.guild_permissions.manage_messages:
...
return
if ctx.author == bot.user:
...
else:
await asyncio.sleep(3)
await ctx.delete()
await ctx.channel.send(f"{ctx.author.mention}, you aren't allowed to say that!")
await bot.process_commands(ctx)
``` guys help `"nope. My bot is spamming me with "@hard trail, you aren't allowed to say that!" every 5 seconds"` brain is off rn
so whats the difference between discord.py and disnake.py
u talk about rust when this is ruby
nothing mostly
disnake is a fork of discord.py and disnake is better.
its a fork of dpy
so i should learn disnake instead
the end of the operation???????
ik
and no need for the ()
but its stupid
there are so many things wrong here 😭
nope
@hard trail so check for a list with words if it is in the list delete the msg and send msg. But if user is a bot or has manage messages keep it?

but this is wrong!
Your not returning
if you dont use return and remove semi colon it returns
😭
num1 + num2 is the same as return num1 + num2;
It does
I was about to say the C and the C++ in me was alerting me
first thing I saw was no semi
fn five() -> i32 {
5
}
fn main() {
let x = five();
println!("The value of x is: {}", x);
}
😔
😂
If it was forced this would be a whole or-deal
fn largest_i32(list: &[i32]) -> i32 {
let mut largest = list[0];
for &item in list {
if item > largest {
largest = item;
}
}
largest
}
how could you not love this
not explicit
fn largest<T>(list: &[T]) -> T {
let mut largest = list[0];
for &item in list {
if item > largest {
largest = item;
}
}
largest
}
```😍
What if I wanted to return something else at the end of the code instead of largest!
Generics are pretty nice though
🙃
I'm for real about to implement application commands before I even add messages to my wrapper
Wait but before you knew that the if part was wrong here
😔
You can still put in return
struct Point<X1, Y1> {
x: X1,
y: Y1,
}
impl<X1, Y1> Point<X1, Y1> {
fn mixup<X2, Y2>(self, other: Point<X2, Y2>) -> Point<X1, Y2> {
Point {
x: self.x,
y: other.y,
}
}
}
beauty
anyways imma stop cuz i dont wanna be banned for off topic
personally, i have fell in love with c# lately
Your such a ruby advocate but so far you've only sent snippets, lets see you make something serious with ruby
👁️ 👁️
give ideas
a challenge
yes
Websocket implementation on ruby
ok so make a bot where when i say balls it puts the 😂 emoji as a reaction
shut up kid
@bot.event
async def on_message(ctx):
if ctx.author.bot:
return
if any([word for word in ctx.message.content if word in naughty_words]):
if not ctx.author.guild_permissions.manage_messages:
await ctx.delete()
await ctx.channel.send(
f"{ctx.author.mention}, you aren't allowed to say that!"
)
await bot.process_commands(ctx)
on ruby?
atleast can u guys help me with this this technically does not have the word youtube in it
yes
No we're still not going to help.
ez opens docs
whyyyyyy
We know your means, please understand.
👀
bruhh
You are knowingly breaking ToS, you know that we won't help with this project.
RUBY
yes
ew
nice
yeah
the interactions and slash commands didn't come early
Okay so imagine this
ruby isnt for heavy processes either
discord.rb implements slower and runs slower
they even say it in the github lol
but discord.rb is literally just discord.py
but moving at a slower rate

hes got a point there
😂
💀
Having a good laugh rn..
switch to guilded?? 👀
drb read me
You should consider other libraries if:
You need to scale to large volumes of servers (>2,500) with lots of members. It's still possible, but it can be difficult to scale Ruby processes, and it requires more in depth knowledge to do so well. Especially if you already have a bot that is on a large amount of servers, porting to Ruby is unlikely to improve your performance in most cases.
You want full control over the library that you're using. While we expose some "lower level" interfaces, they are unstable, and only exist to serve the more powerful abstractions in the library.
🏃
oof now the bot isn't responding now
I migrated away from discord dev to studying O(1) 
Time complexity is quite easy to understand
is there an alternative to make a music bot
or r music bots altogether illegal
cop or drop on JetBrains Rider license
by the way, last time I tried any youtube wrapper the dislike_count is erroring
be careful because yt no likey
oh okay
@commands.command()
@commands.check(permissions.is_owner)
async def adminse(self, ctx, message_id):
"""Sends a message and allows you to edit it"""
async with ctx.channel.typing():
try:
await ctx.message.delete()
except discord.NotFound:
pass
msg = await ctx.channel.fetch_message(message_id)
await ctx.send(
"What would you like to change the message to?", delete_after=delay
)
msg = await self.bot.wait_for(
"message", check=lambda m: m.author == ctx.author
)
await msg.edit(content=msg.content)```
im trying to make a command that allows me to edit a message sent by my bot, but i keep getting this error:
```py
CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 50005): Cannot edit a message authored by another user```
, the message ID is from my bot, so i dont understand what it means
i use webradios n db to store add delete channels @green bluff
Just not possible
You can't edit others messages unless otherwise being the author
"the message ID is from my bot, so i dont understand what it means"
The API thinks otherwise
the api is a nerd 
Oh wait nevermind
You wait for a new message and capture it as msg
You overwrote the previous msg definition
i simplified it a ton
async def edit(self, ctx, message_id, new_content):
"""Edit a message from the bot to say something else"""
try:
await ctx.message.delete(delay=delay)
except:
pass
msg = await ctx.channel.fetch_message(message_id)
await msg.edit(content=new_content)```
i think this would work instead
@reef trail u overwrite msg variable object
Do you know you could also just typehint message_id to discord.Message
Discord.py has a MessageConverter
i did not know that, thanks
check ur msg variable change name on one of em
File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 994, in invoke
await ctx.command.invoke(ctx)
File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 886, in invoke
await self.prepare(ctx)
File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 820, in prepare
await self._parse_arguments(ctx)
File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 726, in _parse_arguments
transformed = await self.transform(ctx, param)
File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 578, in transform
return await run_converters(ctx, converter, argument, param) # type: ignore
File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/ext/commands/converter.py", line 1182, in run_converters
return await _actual_conversion(ctx, converter, argument, param)
File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/ext/commands/converter.py", line 1076, in _actual_conversion
return await converter().convert(ctx, argument)
File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/ext/commands/converter.py", line 395, in convert
raise ChannelNotFound(channel_id)
ChannelNotFound: Channel "None" not found.```
what 
im not even passing a channel..
wait. ctx.channel.fetch_message() is this not a function?
not gonna do it
i have to do it with the bare endpoint which is something im not going to do🚶
hi
channel = Bot.get_channel(-----)
TypeError: Client.get_channel() missing 1 required positional argument: 'id'
@tasks.loop(seconds = 62)
async def myloop(message):
if message.channel.id == channel:
await channel.send("Remember guys! No profanity :) ")
error then code
Traceback?
Any way to make discord bot livestream a clip?
@commands.command()
@commands.check(permissions.is_owner)
async def edit(self, ctx, *new_content):
"""Edit a message from the bot to say something else"""
new_content = " ".join(new_content)
try:
await ctx.message.delete(delay=delay)
except:
pass
channel = self.bot.get_channel(932548255202545664)
msg = await channel.fetch_message(932822132612808725)
await msg.edit(content=new_content)
await ctx.send("Done", delete_after=delay)```
anyone know how to get the content of the message before its edited so you can add new things without having to get the entire message just to add one new item?
hmm
!d disnake.on_message_edit
disnake.on_message_edit(before, after)```
Called when a [`Message`](https://docs.disnake.dev/en/latest/api.html#disnake.Message "disnake.Message") receives an update event. If the message is not found in the internal message cache, then these events will not be called. Messages might not be in cache if the message is too old or the client is participating in high traffic guilds.
If this occurs increase the [`max_messages`](https://docs.disnake.dev/en/latest/api.html#disnake.Client "disnake.Client") parameter or use the [`on_raw_message_edit()`](https://docs.disnake.dev/en/latest/api.html#disnake.on_raw_message_edit "disnake.on_raw_message_edit") event instead.
The following non-exhaustive cases trigger this event...
idk if this was for me, but i dont use disnake
Watch this magic
!d discord.on_message_edit
discord.on_message_edit(before, after)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") receives an update event. If the message is not found in the internal message cache, then these events will not be called. Messages might not be in cache if the message is too old or the client is participating in high traffic guilds.
If this occurs increase the [`max_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") parameter or use the [`on_raw_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_message_edit "discord.on_raw_message_edit") event instead.
The following non-exhaustive cases trigger this event...
wOaH
!d nextcord.on_message_edit
nextcord.on_message_edit(before, after)```
Called when a [`Message`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Message "nextcord.Message") receives an update event. If the message is not found in the internal message cache, then these events will not be called. Messages might not be in cache if the message is too old or the client is participating in high traffic guilds.
If this occurs increase the [`max_messages`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Client "nextcord.Client") parameter or use the [`on_raw_message_edit()`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.on_raw_message_edit "nextcord.on_raw_message_edit") event instead.
The following non-exhaustive cases trigger this event...
no WaAAaaAy
lol
so i have a question. im creating a poll command and im done with it, but i thought it would be a cool idea to dm the analytics of the poll to whoever requests it. so for example a pie chart would be pretty cool
what are you a wizard
so would i have to use matplotlib for this
its just tagging 🤷♂️
i was joking lmfao
lolll
just a method of nextcord

