#discord-bots
1 messages · Page 639 of 1
object.__init__(self[, ...])```
Called after the instance has been created (by [`__new__()`](https://docs.python.org/3/reference/datamodel.html#object.__new__ "object.__new__")), but before it is returned to the caller. The arguments are those passed to the class constructor expression. If a base class has an [`__init__()`](https://docs.python.org/3/reference/datamodel.html#object.__init__ "object.__init__") method, the derived class’s [`__init__()`](https://docs.python.org/3/reference/datamodel.html#object.__init__ "object.__init__") method, if any, must explicitly call it to ensure proper initialization of the base class part of the instance; for example: `super().__init__([args...])`.
Because [`__new__()`](https://docs.python.org/3/reference/datamodel.html#object.__new__ "object.__new__") and [`__init__()`](https://docs.python.org/3/reference/datamodel.html#object.__init__ "object.__init__") work together in constructing objects ([`__new__()`](https://docs.python.org/3/reference/datamodel.html#object.__new__ "object.__new__") to create it, and [`__init__()`](https://docs.python.org/3/reference/datamodel.html#object.__init__ "object.__init__") to customize it), no non-`None` value may be returned by [`__init__()`](https://docs.python.org/3/reference/datamodel.html#object.__init__ "object.__init__"); doing so will cause a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") to be raised at runtime.
I thought just kwargs lol
yeah that will work too
because all the parameters of Embed are keyword only
!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.
yeah
let me guess, this ain't correct.. ```py
import discord
class Factory(discord.Embed):
def init(self, *args, **kwargs):
super().init()
self.embed = Factory(*args, **kwargs)
async def mod_log(self, ctx, title, description, field, value):
embed = self.embed(title=title, description=description, color=ctx.author.color)
embed.add_field(name=field, value=value)
return embed
no
, a good OOP tutorial will explain it pretty easily and quick
the basics of OOP will take around an hour to learn if you pay attention
I have no idea what am I even supposed to do for it to work so I will probably continue it later or just give it up and make embeds manually
it could be a function too but it will not look that good tho
I'll just look up online smth that might work
on member mention?
on_message
check if length of discord.Message.mentions is more than 0
how to get guild description?
!d discord.Guild.description
The guild’s description.
thx
Guys, this is my error: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.utils' has no attribute 'get_role'
@bot.command()
async def snipe(ctx):
Serverbooster = discord.utils.get_role("874795834733117450")
What do I have to change now?
utils is slow, use discord.Member.get_roles instead
discord.Member has to be an instance of the class
Alright
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.
Serverbooster = discord.discord.Member.get_roles("874795834733117450")
!d discord.Member.get_role
get_role(role_id, /)```
Returns a role with the given ID from roles which the member has.
New in version 2.0.
get from the guild
what do you want to do
I've a command.
do you want to check if user has the role
use the decorator, @commands.has_role()
@bot.command()
async def snipe(ctx):
Serverbooster = discord.Member.get_role("874795834733117450")
if not ctx.author.has_role("Server Booster"):
embed = discord.Embed(title="Booster Command", description="Du hast ein Booster Vorteil Entdeckt!",
colour=discord.Colour.red())
!code pls
I did
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.
async def snipe(ctx):
Serverbooster = discord.Member.get_role("874795834733117450")
if not ctx.author.has_role("Server Booster"):
embed = discord.Embed(title="Booster Command", description="Du hast ein Booster Vorteil Entdeckt!",
colour=discord.Colour.red())```
I alried tried has role
its a decorator
But I dont know how to do it if someones doen't have the role, and the person uses a the command
not an attribute
!d discord.Member.premium_since check this as well maybe thats what you want
An aware datetime object that specifies the date and time in UTC when the member used their “Nitro boost” on the guild, if available. This could be None.
yeah, and?
I don't get why you use discord.Member as well, you need to use ctx.author
if not ctx.author.has_role("Server Booster"):
member has no has_role attribute
Yeah
you have to check if its in its roles
Got that error rn lol
hello
Wdym?
sup
so i have dis work command
@bot.listen()
async def on_message(message):
if message.content.startswith('!work'):
channel = message.channel
await channel.send('print hello world')
player = message.author
gg = random.randint(100, 150)
def check(m):
return m.content == "```py print('hello world')```" or '```print("hello world")```' or "print('hello world')" or 'print("hellow world")' and m.channel == channel
msg = await bot.wait_for('message', check=check)
c.execute(f"UPDATE data SET balance = balance+{gg} WHERE ID = {player.id}")
conn.commit()
await channel.send(f"You Worked Hard To Fix The Bug, You Got **{gg}:nexus:** as Salary")
print(gg)
so I am trying to make a function such as work "list"
i currently have 3 works such as this types and want to make a command such as
!work {work_name}
and allow the users to take 1 work out of 3
role_ids = [r.id for r in ctx.author.roles]
if not ROLEID in role_ids:
...
wouldnt recommend this, so long, another way would be getting the role. u could use a decorator
wut
@silk mauve
the code seems to be weird because its python language
have you used dank memer?
?
soo i am trying to make a command such as
!work {work_name}
and i have 3 work names
naming
coder
gamer
artist
cool
and if the person types
! work coder
than the user cannot use
work command of gamer or artist
can you pls help me to make this system
Do you guys know the minimum amount of time between messages from a loop I can send at?
I'm trying to make a bot that sends a message every hour.\
coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.
If *result* is provided, it is returned to the caller when the coroutine completes.
`sleep()` always suspends the current task, allowing other tasks to run.
Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.
Deprecated since version 3.8, removed in version 3.10: The `loop` parameter. This function has been implicitly getting the current running loop since 3.7. See [What’s New in 3.10’s Removed section](https://docs.python.org/3/whatsnew/3.10.html#whatsnew310-removed) for more information.
Example of coroutine displaying the current date every second for 5 seconds:
no asyncio sleep, use tasks from discordpy
Huh
Oh, ok.
@tasks.loop(hours=1)
async def myloop():
# do stuff
epic nitro fail
makes sense
:sadge:
I guess I wait the 5 minutes and see if it sends
I mean
I told people to Google it
I don’t know why they hate me for this
async def myloop():
response = "Hugu Wugu"
await ctx.send(response)
channel.send(response)```
yeah, uh, don't do that.
any prollums here?
there's no ctx, you need to get the channel from its ID
on loops too eh?
Why
What’s wrong with that
It’s the obvious answer 🤷♂️ unless you already searched it up or nothing happens
rude, also anyone can guess googling may lead to answers
Your just making it send a message each hour if you added a hour
Damn
I guess they don’t like googling
And plus they just come directly into discord
So your iterating through a list and you want each element to send with a delay of 1hour?
yes there's no ctx on loops
https://discordpy.readthedocs.io/en/stable/ext/tasks/index.html
this will help you get started with tasks
how do people usually go about running webservers and sharing data with a discord bot? do they have it run on the same event loop or is it different processes?
communicating with a DB or something else
each service makes requests to the database, bots do too
you just have to implement it
ah gotcha
I'm getting TypeError: myloop() missing 1 required positional argument: 'ctx'
async def myloop(ctx):
response = "Hugu Wugu"
await ctx.send(response)
myloop.start()```
is the ctx wrong?
What are you tryng to do?
send hugu wugu 5 times upon start up of bot?
u need to pass a parameter for ctx to the start method
Make a function and create a task loop
name ctx is not defined is what i'm getting now
for myloop.start(ctx)
yes, but ultimately I want it to send a message every hour 😐
But u need to use bot.get_channel to get the channel
where do u want to send the message
general
The bot doesn't know what is general
You can do something like
@tasks.loop(...)
async def loop():
await bot.wait_until_ready()
channel = bot.get_channel(id)
await channel.send(...)
loop.start()
Welp I just spoonfed ;-;
Stilllllll
what's the import for that?
no...
None 😄
module 'discord.ext.commands.bot' has no attribute 'get_channel'
it should auto import from discord.ext import tasks
do
import discord
from discord.ext import commmands
as your first two imports
not discord.ext.commands.bot
i dont think they even opened the link i sent
class discord.ext.tasks.Loop```
A background task helper that abstracts the loop and reconnection logic for you.
The main interface to create this is through [`loop()`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.loop "discord.ext.tasks.loop").
oh yeah
for embed this is incorrect, but what is correct one? ```py
icon_url=member.display_avatar.url
member.avatar.url
ah
hey i have a problem in my code
with open('songs') as f:
lines = f.read().splitlines()
print(lines)
for line in lines:
count=+ 1
results = YoutubeSearch(line, max_results=1).to_dict()
if len(results) > 0:
dictionary = results[0]
songs_urls =(f"youtube.com{dictionary.get('url_suffix')}")
with open('songs','w') as f:
f.write((songs_urls) + '\n')
else:
print("No results found.")
f.close()```
this is my code when i try to write the songs_urls in a txt file it write the url but write it and then remove it and write new one and keep doing this
i want it to write one and then go to anther line and go to the for loop and write the other one
even when im using writelines same problem any idea how to fix it ?
So you want us to help with sync code that relates to Discord.py?
!blocking
Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.
What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:
import discord
# Bunch of bot code
async def ping(ctx):
await ctx.send("Pong!")
What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.
async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!
pandabweer
how would you get mutual members in python (im making a modmail bot)? Ik you can do it in js but how would we do it in py
mutual members?
!d discord.User.mutual_guilds is what u mean
property mutual_guilds: List[Guild]```
The guilds that the user shares with the client.
Note
This will only return mutual guilds within the client’s internal cache.
New in version 1.7.
yh thx
idk how to word stuff
@slate swan :x: Your eval job has completed with return code 1.
001 | a='a=%r;print(a%%a)';print(a%a)
002 | Traceback (most recent call last):
003 | File "<string>", line 3, in <module>
004 | File "<string>", line 1
005 | print('exec("print('''Hello, World!''')")')
006 | ^
007 | SyntaxError: unterminated triple-quoted string literal (detected at line 1)
#bot-commands exists
Hi, I am trying to make an event to send a message in a channel that the bot has permission to send in on join. I have this so far but it does not work and no errors are produced.
@commands.Cog.listener()
async def on_server_join(self,ctx):
for guild in self.bot.guilds:
for channel in guild.text_channels:
if channel.permissions_for(guild.me).say:
await ctx.message.channel.send('Hello! \n')
break
My name! 
Pandabweer

Such a nice name
Can someone tell me how i can keep my discord bot up with a html?
html is a markup language…. what correlation does that have with keeping your bot running. 
Idk
99.9 percent sure that event doesnt take in ctx.
my freind told me that with html the bot would keep being online
But that’s not what really matters.
instead of ctx.message.channel.send() it’s just supposed to be channel.send()
ah ok
10000% sure on_server_join is from 2015 lol
oh lol
on_guild_join() pl0x
!d discord.on_guild_join
discord.on_guild_join(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") is either created by the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") or when the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") joins a guild.
This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
So something like this
@commands.Cog.listener()
async def on_guild_join(self,guild,ctx):
for guild in self.bot.guilds:
for channel in guild.text_channels:
if channel.permissions_for(guild.me).say:
await channel.send('Hello! \n')
break
don't need ctx
Yeah but what is the reason for the spamming?
Well it does exactly what you want it to do.
Yes this is code for a nuke bot so we don't help creating that here.
Sends a message in every chat the bot has perms in
But is there some kind of method to keep a discord bot online so i dont have to pay for a vps or have mig pc open og day all night
oh no
I definitely don't want that
I'm not trying to make a nuke bot lol
How do I make it so It only sends once?
I used that yeah
Id honestly just a pick a random channel. For your use case.
If I don't know how to do something where else do u want me to go?
random.choice() on Guild.channels
And send it to that one
Or better yet
Use the system messages channel
@commands.Cog.listener()
async def on_guild_join(self, guild: discord.Guild) -> discord.TextChannel.send:
return await guild.system_channel.send('Hello!')
``` Don't think too difficult guys
Could you show it?
the error as well pls
There was no error but dw I fixed it. It was an indents problem
So time for a beer?
yes
🍻
Why you annotating to None if your returning something 

Lemme fix
Done
you could of just annotated it to discord.Message but that’s ok 👌
got everything fixed in anther channel ty anyway
Web servers could work but..m
Bot hosting is really really cheap and easy
but its not a bot i wanna make a profit of i just want to be able to close my pc so my house dont burn to hell
It's not a discord bot?
Idk, I wouldnt recomment replit or heroku tbh
yea replit is not strong but when i close the web the bot closes too
Uptime robot?
Closes it?
yea
Weird
The bot shutdown when u close the web(replit)
You're using uptime robot or not?
what is that?
Thats what keeps your bot online even when you shut down your computer
Constantly pinging your bot's web server every 5 mins for free
But you need to refresh your repl every 9 hours
I thought you have to pay
How is this invalid syntax?
return await guild.system_channel.send(embed=em)
^
SyntaxError: invalid syntax
how do I catch a discord interactions timeout error?
interaction = await self.bot.wait_for("button_click", timeout=30)
errr
I think you dont have to await it
it's not like that
How do I make the commands have description when showing the help command?
idk how to use the bot
Do you mean in an embed?
yeah I can't find any api for discord interactions
I mean you can delete the help command
it makes it hard
no...
example = bot.wait_for("message", check=check, timeout=30)
return guild.system_channel.send(embed=em)
^
SyntaxError: invalid syntax
I might be wrong but you can probably just do this
async def teams(self, ctx, description="description"):
show full code
how'd you find this
wont work I think
I dont think that would work ;-; but I mean you can try
@commands.Cog.listener()
async def on_guild_join(self, guild: discord.Guild) -> discord.abc.Messageable.send:
em = discord.Embed(title = "Title", description = "Description",colour=0x3FE452)
em.add_field(name="Name", value="Value"
return guild.system_channel.send(embed=em)
i get this err or but my code still works nextcord.errors.InteractionResponded: This interaction has already been responded to before my code : py @nextcord.ui.button(label="testlabel",style=nextcord.ButtonStyle.grey) async def Field1(self,button : nextcord.ui.Button,interaction:nextcord.Interaction): while True: await interaction.response.send_message("Dein spielfeld XD",ephemeral=True)
intellisense autocompleted it that's why i suggested it
Like- would it be like this??
@client.command(brief=“brief”, description=“description”)`?```
where did you find this though
i used this guide https://www.showwcase.com/show/11710/Host-a-Discord-Bot-online-247-for-FREE! to get my bot to run 24/7 but it wont show a website window on repl pls help ```py
import os
import discord
from discord.ext import commands, tasks
import re
from urllib.request import urlopen
from bs4 import BeautifulSoup
import requests
import random
from itertools import cycle
from flask import Flask
from threading import Thread
app = Flask('')
@app.route('/')
def main():
return "Your Bot Is Ready"
def run():
app.run(host="0.0.0.0", port=8000)
def keep_alive():
server = Thread(target=run)
server.start()
bot = commands.Bot(command_prefix="!")
bot.remove_command('help')
case_insensitive=True
status = cycle(['!help','!scs <product>'])
@bot.event
async def on_ready():
change_status.start()
#os.system("clear")
print("{0.user} is online".format(bot))
@tasks.loop(seconds=10)
async def change_status():
await bot.change_presence(activity=discord.Game(next(status)))
I tried doing that, nothing happened
...
I'll look into it
thanks :)
bruh it's javascript
oh wait there is a python section
guys how do i add emoji reaction for the bots message
any errors?
await msg.add_reaction?
no
I've been trying to make a bot using discord.py add a reaction to a message using discord.py after reading this (which is not what I wanted because I am not using custom emojis) but it ends up giving
what happens?
what window
that white thing
it is showing?
no
no?
its not showing
It says "I'm alive"
show me the link?
i dont have it
what do you mean?
this is what i get
when you create a flask repl, there should be a link...
yep ik
but it doesnt work
i cant as i dont have a link
wdym
UptimeRobot is a website
i know
but this should be a #web-development question, as it does not apply to discord bots (fully)
but i dont have a https link that i could put there
he doesn't have a link, it won't work
okay
What does it look like right now?
.
there is a screenshot
Run the flask code in another file
how?
I have no experience with Flask, but my Django projects work pretty well
we dont talk about the time where I spent hours trying to pip install django
Then import it in the main file
lol
won't work...?
how do i do that ?
create a new file, and then from example import * but I dont think it'll work
okay
okay
I never really used replit
helllo i have a question
yes?
import webserver
from webserver import keep_alive
i have that
i know it may sound dumb but how can I edit a channel ? idk if i must do channel.edit(blablabla) or another thing like await channel.edit. and can you tell me how to do the command becuse i doont understand the "reason" and where to put the channel's id or name to change it with a new name
How can I check if a user joined in the last 24 hours or not?
as the docs say, it's await, and everything is an optional kwarg
there's a member.joined_at, which is a datetime object so you can compare it to something like utcnow()
!d discord.Member.joined_at
An aware datetime object that specifies the date and time in UTC that the member joined the guild. If the member left and rejoined the guild, this will be the latest date. In certain cases, this can be None.
and how do I do it with the last 24hours
subtract utcnow and the joined_at, and you get a timedelta
!d datetime.timedelta
class datetime.timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)```
All arguments are optional and default to `0`. Arguments may be integers or floats, and may be positive or negative.
Only *days*, *seconds* and *microseconds* are stored internally. Arguments are converted to those units...
what is a kwarg ? what does the * stand for ? do I write the name directly or name("newame")
- stands for kwarg in this context
keyword argument
can you do an example of the edit fuction please ?
await channel.edit(name="hello world")
!args-kwargs
*args and **kwargs
These special parameters allow functions to take arbitrary amounts of positional and keyword arguments. The names args and kwargs are purely convention, and could be named any other valid variable name. The special functionality comes from the single and double asterisks (*). If both are used in a function signature, *args must appear before **kwargs.
Single asterisk
*args will ingest an arbitrary amount of positional arguments, and store it in a tuple. If there are parameters after *args in the parameter list with no default value, they will become required keyword arguments by default.
Double asterisk
**kwargs will ingest an arbitrary amount of keyword arguments, and store it in a dictionary. There can be no additional parameters after **kwargs in the parameter list.
Use cases
• Decorators (see !tags decorators)
• Inheritance (overriding methods)
• Future proofing (in the case of the first two bullet points, if the parameters change, your code won't break)
• Flexibility (writing functions that behave like dict() or print())
See !tags positional-keyword for information about positional and keyword arguments
so i have this:
try:
role = 'Staff'
await client.wait_for("message", check=lambda m: m.channel == ticket_channel and m.content == "!close", timeout=3600)
except asyncio.TimeoutError:
await ticket_channel.delete()
else:
await ticket_channel.delete()
and i want to check if the user who sent the msg has the role Staff how would i do that. lmk if i should post the whole code
something like this
role = discord.utils.find(lambda r: r.name == 'Member', ctx.message.server.roles)
if role in user.roles:
await bot.say("{} is not muted".format(user))
else:
await bot.add_roles(user, role)
How to make a add roles for user by using buttons?
i already tried that it justs deletes the channel as soon as its made
Read the docs for button, there is a way to overwrite callback function
It’ s all in the docs
what how is that
where is the docs? send link please
no clue tbh. but as soon as the channel gets opened it gets deleted
thank you I understand now
Idk what library u use for components
Read docs from library ur using
hi enslo
Hi
Ignoring exception in command collatz:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 855, in invoke
await self.prepare(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 789, in prepare
await self._parse_arguments(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 697, in _parse_arguments
transformed = await self.transform(ctx, param)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 542, in transform
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: num is a required argument that is missing.```
help i tried doing collatz conjecture on a discord bot and this is the error and i understand none of it
I’m trying to make a bot command where if you ping bot it gives prefix
it says num is a required argument that is missing.
does anyone know how to use the check parameter with buttons
msg = await client.wait_for('message', check=check)
if its a button why are you waiting for a message
it's an example
interaction = await client.wait_for('button_click', check=check)
there
you can make it check=lambda interaction: interaction.author == ctx.author, although it depends on what library you're using.
awesome I modified what you sent a bit and it works exactly how I want it to
😉
so i have a category called tickets and i when i do the command $close in a channel, i want that channel to be deleted how would i do that?
is your prefix $?
You use .delete attr
!d discord.TextChannel.delete
await delete(*, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Deletes the channel.
You must have [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.
await ctx.channel.delete()
yes
how would i check if the channel is in a specific category?
hi i have a bot that pulls posts from reddit by copying the link into discord and discord auto embeds it. the issue is sometimes the post is not a jpg or png and it doesnt properly embed so is there anyway to identify the link type before it sends?
!d discord.TextChannel.category || you make a command called close, check if its in the category, and then do await ctx.channel.delete()
property category: Optional[CategoryChannel]```
The category this channel belongs to.
If there is no category then this is `None`.
what does the link look like?
sometimes it has the file ending in the link
Check the url with .endswith(".jpg" or "png") i think it would work
not always
How so?
thats why im asking what the link looks like
Hes searching for many links so i think he cant specify it
its usually your normal i.redd.it / example .jpg
if it ends in the file ending, then you can do okami’s method
but not all links end with the file suffix
a link could just be an object
help
how to fix
async def close(ctx):
if discord.TextChannel.category == 914974724914827314:
await ctx.channel.delete()
where would i put that?
yeah ive been working with it and it works perfectly thanks
Nice,your welcome
how can i invoke something in a command so i can have more room for arguments? like
async def globalnote(ctx, member : discord.Member, guild : discord.Guild, note):. it says that certain arguments are required but even if i provide them all it wouldnt work
does anyone know what i mean or shall i explain more
what do you mean by it doesn't work?
Ok so I made a suggest command and here is the main code:
@commands.command(name="Suggest", brief="*Send a suggestion to our suggestions channel to suggest things for bots, channels, events, etc.*")
async def suggest(self, ctx, suggestion):
embed = discord.Embed(
title = "Affinitys Advertising New Suggestion",
description = f"*{suggestion}*",
color = 0xFF8000,
timestamp = ctx.message.created_at
)```
there is more but this is the main
When I use the command and I use multiple words spaced out it only sends the first word
not the entire sentence
yeah, you need to consume the rest of the arguments
you would call it like if you were using keyword-arguments
def functionName(positionalArgument1, *, keywordArgument1, keywordArgument2, ...):
# code here
I dont understand why I would need to do that so manually
That's just how the library is designed
there has to be a discord.py way to do it.
No, this is how the docs tell you to do it as well
Alternative is to keep it like you have right now, and use quotes around multi-word arguments
where do I put as the ```py
code here```
such as
!commandName "multi word argument"
whatever your code inside the command is
so like: ```py
@commands.command(name="Suggest", brief="Send a suggestion to our suggestions channel to suggest things for bots, channels, events, etc.")
def functionName(positionalArgument1, *, keywordArgument1, keywordArgument2, ...):
async def suggest(self, ctx, suggestion):
embed = discord.Embed(
title = "Affinitys Advertising New Suggestion",
description = f"*{suggestion}*",
color = 0xFF8000,
timestamp = ctx.message.created_at
)......```??
wait shit
what i provided was only psuedocode, don't copy and paste it
i was only demostrating a concept
I have to find someone else, this is helpful sorry
?
!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.
@client.event
async def statuschange():
await client.wait_until_ready()
while True:
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="a song", url="song"))
Why does this not work?
most likely because statuschange is not a valid event name
If you want to get the entire suggestion you can do
async def function_name(self, ctx, *, suggestion): ...
I've used it in the past, no issues
well what errors do you get this time?
no error, just the bot doesn't have a status
this is what i meant, just didn't wanna spoon feed haha
Everything except calling the command will be stored in suggestion
is there somewhere in the dev portal that I have to enable?
that makes sense, it's not a valid event so i don't see why it's getting called
prehaps you didn't mean to have the decorator?
thank you so much, I will try it
Also, what's calling the coro?
How is this spoon feeding? Its nothing less than what you did
I also just have no idea what the * is called
- statuschange is not an event unles you're using some super weird library that does that
- your will absolutely kill your rate limit and probably get yourself API banned
And if it even has a special name
How can I fix 🙏
don't use a while True
look at those 2 things i mentioned
also, the recommended way to have good status changing is using the tasks extension
Set a task for, say, 60 seconds and change it like that
or just not use some weird status updater because they are often super annoying
Common mistake i see people making is also setting the presence in on_ready, you shouldn't do that
I understand the fact that just telling them the answers isnt ok, but what I was asking wasnt spoon feeding. I was wondering how I can get this commmand to work and what I do to make it work and how it makes it work.
you should set it to a few minutes, iirc the last known rate limit on custom status was like 2 per 10 minutes
similar to channel edits haha
whats the event name for status?
Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send'```
Code?
@commands.command(name="Suggest", brief="*Send a suggestion to our suggestions channel to suggest things for bots, channels, events, etc.*")
async def suggest(self, ctx, *, suggestion):
embed = discord.Embed(
title = "Affinitys Advertising New Suggestion",
description = f"*{suggestion}*",
color = 0xFF8000,
timestamp = ctx.message.created_at
)
embed.set_footer(text=f"Requested by {ctx.message.author} | ID-{ctx.message.author.id}" .format(ctx.message.author, ctx.message.author.id))
channel = bot.get_channel(911686489782489177)#907446181624447066
await channel.send(embed=embed)
await ctx.send("*Suggestion sent to the servers bot suggestion channel.*")```
its the *
Yep, that would consume all the arguments
What is “status” supposed to represent?
the bots status (listening, watching, etc)
on_presence_update i think
I think they want the event when bot detects a status update?
no, when the bot is online I want the status to show
That triggers if any member the bot can see updates their presence (which includes but is not limited to status)
You mean on_ready?
Just add it to activity= in the bot constructor
where?
i have a command that adds notes to users as per guild, how can i use pages to limit it to 10 per page and add an argument for the page like ^notes <user> <page> to prevent bot lag using button reactions? the notes are stored in a txt file by the way
Read the message
How are you running the command?
??
If you add it to the bot constructor, it gets send with the identify payload to discord, which is the intended way
What are you typing in to discord to run the command?
f!suggest <suggestion>
how can i start this file ? the \f is annoying
I misread the error. Its saying that channel is None. Are you sure the id is correct?
How can I do watching and add a link? @valid niche
I thought I could just add url=""
but doesn't seem so
yes, but I will try to paste a new
!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")
ummmmmmmmmmmmmmmmmmmmmmm
Also this is wrong embed.set_footer(text=f"Requested by {ctx.message.author} | ID-{ctx.message.author.id}" .format(ctx.message.author, ctx.message.author.id))
!d discord.ext.commands.Bot
class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
so I remade the suggestion channel, and I forgot to fix the id
Pick either f strings or .format
no
it works
The code works but it doesn't make sense
activity=discord.Activity(type=discord.ActivityType.watching, name="Twitch", url="https://www.twitch.tv/"))
@valid niche
@slate swan
Using them at the same time is useless
i have a command that adds notes to users as per guild, how can i use pages to limit it to 10 per page and add an argument for the page like ^notes <user> <page> to prevent bot lag using button reactions? the notes are stored in a txt file by the way
I’m going to kindly ask you to stop doing @valid niche thank you
oh my bad
k
can anyone else help?
!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.
how would i make this send in dms instead of the channel?
import discord
from discord.ext import commands
from datetime import datetime
attributes = {
'name': "help",
'aliases': ["commands"],
'cooldown': commands.Cooldown(1, 5, commands.BucketType.user)
}
# Unimportant part
class MyHelp(commands.HelpCommand):
async def send_bot_help(self, mapping):
channel = self.get_destination()
embed = discord.Embed(
title="Bobert Help!",
description="Welcome to Bobert's official help menu! Bobert is the official utility and moderation bot for test server.\nFor more in depth help and info regarding the use of Bobert, you should contact @outer violet as this command only shows information about commands.\n\n***Use the reactions below to change pages***",
color=0x2f3136,
timestamp=datetime.utcnow()
)
await channel.send(embed=embed)
class YourCog(commands.Cog):
def __init__(self, client):
self.client = client
# Focus here
# Setting the cog for the help
help_command = MyHelp(command_attrs=attributes)
help_command.cog = self # Instance of YourCog class
client.help_command = help_command
def setup(client):
client.add_cog(YourCog(client))```
await self.context.author.send(...)
ok
👀
I added slash commands to my bot but the commands say "Interaction failed". my code is correct
it only happens to commands that dont have a ctx.send
await defer(*, ephemeral=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Defers the interaction response.
This is typically used when the interaction is acknowledged and a secondary action will be done later.
should I add some type of response? maybe it will fix it from saying the error
Use this
can I see an example
await ctx.response.defer()
what does it do exactly?
Do you know that some bots do the thinking reply?
yes
That's what it does
my bot is doing that, then responds with the Interaction Failed
So I can just add await ctx.response.defer() ?
AttributeError: 'SlashContext' object has no attribute 'response'
Ah don't use that one
Why?
Idk I never used it but people say that it's broken and doesn't work properly
which is better?
!pypi disnake u can use this. It's a dpy fork with slash commands and buttons too
will discord.py code work with it
Sure
how do I use slash commands with it?
You just need to change your imports to disnake
wdym?
Like change import discord to import disnake and stuff
only once though right?
else how am I gonna import datetime, os etc
Ah u will be able to do those like u r doing those rn
so i only change the import discord?
Yea
so I completly remove my import discord?
And also imports like from discord.ext import commands to from disnake.ext import commands
from disnake.ext
There are examples (:
Yea
But if u r using VSCode, just search discord and right click and then select change all occurrences
can u send an example
?
of the slash commands
^^^
Those are different types of slash command
I just need regular ones
One is with autocomplete, other with options
difference?
Kk lemme share
basically all I do is change the .command to client.slash_command()
https://github.com/DisnakeDev/disnake/blob/master/examples/slash_commands/subcmd.py
Ignore the decorator with @command.sub_command() deco, u don't need those
discord voice client
AttributeError: 'ApplicationCommandInteraction' object has no attribute 'voice_client'
well it's only happening for my commands that are in cog
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.
If you still need to know, it basically tells Discord's servers, "Hey, I received the interaction, I'm not gonna do anything just yet, but just know that I got your request"
I.e a fake response
It comes in handy when you want to do the *_original_message functions
can you help me with something
To the best of my ability, I'd be glad to 😄
can we go to dms
Sorry but I don't do dm help
oh
You can ask here and I'll help, others will be able to chime is as well
Command raised an exception: AttributeError: 'NoneType' object has no attribute 'channel'
!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.
The guild ID is probably incorrect, though I'd need to see your code to properly diagnose the issue
Ohh, that happens when the author isn't in a voice channel
the bot does return "You're not in a voice channel"
It does both at the same time?
Makes sense, it doesn't care if you're in a voice channel or not when it tries to find the channel
You should add an else after the first if, and move the voice_channel variable into it
it only does "You're not in a voice channel!" when I try running the command without being in a voice channel
and it says "Successfully joined the voice channel!" When I am in a voice channel
does not do them both at the same time
how do I make it so the error does not occur in the Console
It's supposed to do this?
No
it does everything correctly
Im asking how I can make it so the error Command raised an exception: AttributeError: 'NoneType' object has no attribute 'channel'
does not happen in the Console
Can you post the full traceback? Maybe it's happening somewhere else
So its only where i thought it was
So?
When exactly does the error happen again?
when I do /join but am not in a voice channel
return it
return await ctx.send("You're not in a voice channel!")
this command is inside of a cog btw
it works as it should? why do I need to add return
to exit the function
ok let me try that
should I add return to await ctx.send("Successfully joined the voice channel! ✅")
aswell?
it's the end of the code so no need
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)
@bot.command(aliases=['latency', 'ping', 'ram', 'cpu', 'hostinfo'])
async def state(ctx):
#hidden important stuff
if CPU_usage < 50:
cpuu = ""
elif 50 < CPU_usage < 75:
cpuu = ""
elif 75 < CPU_usage:
cpuu = ""
if RAM_usage < 50:
ramu = ""
elif 50 < RAM_usage < 75:
ramu = ""
elif 75 < RAM_usage:
ramu = ""
if ping < 75:
ms = ""
elif 75 < ping < 180:
ms = ""
elif 180 < ping:
ms = ""
embed = discord.Embed(title = 'Status', description = f'{cpuu} {CPU_usage}%\n{ramu} {RAM_usage}%\n{ms} {ping}ms', color = 0x2f3136)
embed.set_author(name=f'{bot.user.name}#{bot.user.discriminator}', icon_url=bot.user.display_avatar)
await ctx.send(embed=embed)```
error:`discord.ext.commands.errors.CommandInvokeError: Command raised an exception: UnboundLocalError: local variable 'ramu' referenced before assignment`. ive defined ram_usage, ping, and cpu_usage as the proper objects (refuse to show due to larps and skids). i dont know why the command fails, could someone help?
the command works sometimes, then sometimes it doesnt
i think its an error with the values ive provided in the intervals
if RAM_usage < 50:
ramu = ":RAM:"
elif 50 < RAM_usage < 75:
ramu = ":RAM:"
elif 75 < RAM_usage:
ramu = ":RAM:"``` any of these conditions is not fulfilled
it's happens when your ram is accurately 75
how can i fix that
elif 50 < ram_usage < 75 or ram_usage = 75?
ram_usage <= 75
i see, thanks
should i be worried about my bots future since discord.py is abandoned ? any advice ?
i just need to import one of the fork instead of discord.py ? or needs to change the syntex as well
idk about others, but if you use disnake, you just gotta replace discord. to disnake.
i heard pycord changed the path of Bot subclass, so you might have a hard time with that one
okay..my bot has about 4k lines and i was worried about discord.py
forks are pretty good, shouldn't be something to be worried about
if you want something entirely new with new syntax, you could try hikari
so disnake you recommand ?
yes
Can I connect a website to other websites and then put a command my bot?
they also have a version, where you dont even have to change your code
i want to spend least time on changing code i have
uninstall discord.py and install that thing
Nextcore?
With disnake, just change the imports and boom, u r done :D
however its not recommended to do that
disnake
Ok
Why do you need to uninstall discord.py to use disnake?
It doesn’t make sense
great..my browser history had started filling up with js guides😅
im talking about a different branch
disnake[shim]
Ah
I remember seeing disnake in their FAQ that you should uninstall discord.py
Was wondering the reason for that
maybe they were talking about that one
if you use that version, you dont have to replace anything in your code
but idk if its updated that often
Still wouldn't explain why you would need to uninstall discord.py to use disnake
you dont need to uninstall it if you use the normal branch
So are you saying that if you use a different branch you need to uninstall discord.py?
the shim one replaces the files of discord.py
the shim branch will replace the original discord.py files, its better to delete it
Disnake and discord.py are separate packages... Disnake can't change discord.py files lol
it can :/
In python you have you packages folder, and those are separated
class one(commands.Cog):
"""Cog description"""
@commands.command()
async def earth(self, ctx):
"""Command description"""
await ctx.send("Pong!")
class two(commands.Cog):
"""Cog description"""
@commands.command()
async def mars(self, ctx):
"""Command description"""
await ctx.send("Pong!")
bot = commands.Bot(command_prefix="!")
bot.add_cog(one())
bot.add_cog(two())
bot.run('token')
I'm unsure how the disnake library would override those files in a different folder...
is this the correct format for cogs
there are extensions for disnake
dont make another bot instance. And dont run the bot again in the cog.
umm how to make this work
if you pip installl them
i want make like if ?help show main help embeds cuz i have another classes of cmd
I don't even see a shim branch for disnake
Unless I'm looking at the wrong repo
they move it to the original ext folder of the library
i need to catergorize my help commands...can i do that with something simpler
Where I don't see it
class one(commands.Cog):
"""Cog description"""
@commands.command()
async def earth(self, ctx):
"""Command description"""
await ctx.send("Pong!")
def setup(bot):
bot.add_cog(one(bot))
idk if its a branch or not, but it works if you try to install it
install an extension for discord.py, and then check your ext folder of the discord.py package folder
Give me a second
what about second catergory ? one , two , three
you don't want to make different folders for different cogs? That's normally more organised
thats not an extension
one sec i have to check if its available or not
Isn't that how you install optional stuff on pip??
i have no idea about cogs i just read this
And I just went off of what you sent
I cannot install from a repo branch as one literally doesn't exist..
try git+repourl
maybe its work
Did you even read what I said??
yep
So how would installing from the repo url do what I want
hi
idk if it still exists or not, its been a while i chcked
I don't get what you mean
Have you installed this package thing before hand already?
wait is the repo doesnt exits?
it worked before
And did your discord.py exts folder get overwritten
oh you want cogs in your main file
And why is that
i thought it should be easy to make catergory for my help commands
maybe it doesnt but still python can't guess which one you want to use so you gotts uninstall that thing
These are two separate packages, one is a fork of the other so the fork has literally all the methods and classes of the other one. You don't need to overwrite the old package in order to use the new one, because the fork literally has all the implementations
i make custom help on main.py lol
???? If python couldn't do that I'm pretty sure that would be a huge issue and a crazy bug that would've been fixed already
Lmao... I even mentioned early python packages get their own folders so that makes no sense either way
looks like you're confused what the shim version is for
What is it for then
you want to make a cog in your main file or in a different file?
if you install it, you dont have to replace discord to disnake, instead the entire package is named discord so no need to change imports
That probably replaces sys.module
Lol???
and how would you use both of them ?
How can I use slash commands for a client.group using disnake?
Keyword replaces
what?
I'm not saying it doesn't allow you to use disnake without changing imports, but what I'm saying is that it DOESN'T CHANGE DISCORD.PY FILES
!e ```py
import sys; sys.modules["math"] = import("random")
@pliant gulch :warning: Your eval job has completed with return code 0.
[No output]
what im saying is that you can't use both the original discord.py and shim by your choice
you gotta keep one
unless there are some weird workarounds im unknown of
🤔
it says help is already an existing command
do bot.remove_command("help")
no idea...can you explain whats the difference pls
i kind of agreed with you there that it may not replace the orignal files
put help_command=None in your bot constructor
i see ok
wrong reply i think
How can I use slash commands for a client.group using disnake?
bro can u help my problem?
nope
generally cogs are made in the different file from the main
i think
yes
whats the problem?
here
import sys
sys.modules["discord"] = __import__("disnake")
sys.modules["original"] = __import__("discord")
@brave flint https://tutorial.vcokltfre.dev/tutorial/05-cogs/
Cogs are a very important part of discord.py which allow you to organise your commands into groups - not to be confused with actual command groups, which will be explained later in the tutorial.
ok i dont need cogs...i will make my own help command😂 ..thanks for guiding me to the right path
so you gotta do that everytime you want to use it or what
also what is original
wut?
i alr know bout cogs
original is discord, so you can do import original and it would be discord
wrong ping sorry
And yes obv you have to do that if you want to use them both, cause obv from what you said the shim ext overwrites the import...
If you are that lazy to not want to change imports then I'm sure that wouldn't be a big deal to use both
but isn't the original also named discord
or original is some special prefix or smth
🤔
!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.
where do you put this this code
in your file or some other files in the package folder
Youve done that command like 10 times already?
I need the code
lmao
Just .bm it and why mobile has it and so does desktop
whats eval
evaluate
a function
I would put it inside of an __init__
ok
at this point someone would just replace discord with disnake and not override imports
but how you all manage to keep track like so many messages per second
If its a complicated code block use
exec(a)
just keep adding them to a variable after a second, easy
Sure, but some people are just lazy
hey I am talking about this server
I don't really care about that, I just don't see the reason why discord.py needs to be uninstalled when using disnake
I don't even know why it says that in the FAQ either
Many people ig🤷♂️
if @unkempt canyon is written in python, then its easy
No like how do WE keep up with so many messages
Hello I dont know Why isn't it working
py await client.change_presence( activity=discord.Activity( type=discord.ActivityType.watching, name= str(len(client.guilds))+ sum(1 for g in client.guilds for _ in g.channels), ) )
Wait nvm
wdym

it doesn't, i checked maybe they discontinued the branch
use activity command in bot constructor
Are you in the disnake server?
wait
yes, im gonna go afk now
Before you afk, type /faq in the disnake server
It will say somewhere to uninstall discord.py before installing
commands.Bot(command_prefix=prefixes, intents=discord.Intents.all(), help_command=None, activity=discord.Activity(type=discord.ActivityType.listening, name=".help"))
like this ^
oh ok
thanks
welcome
but I want total number of servers
and client is coming undefined
What's the meaning of
class Btn(discord.ui.Button["Btn"]):
pass
then write your logic
but client is important
wdym
which is undefined
!d discord.Client.guilds
property guilds: List[discord.guild.Guild]```
The guilds that the connected client is a member of.
code
how would you count without client
code
client = commands.Bot(
command_prefix= (get_prefix),activity=discord.Activity(type=discord.ActivityType.listening, name=str(len(client.guilds)))
Eevee do you know
Ah
so?
....
U need to do
client = commands.Bot(...)
client.activity=...
In a separate line
e.listening, name=str(len(client.guilds))))
NameError: name 'client' is not defined
what do I know...
uh nice....
^^^
see error
didn't I just tell u the answer
I'm broke on buttons
lmao
you say nice , people would bash on me for keeping my bot off for so much time
Okay so do u know the meaning of
class Bot(commands.Bot["Bot"]):
pass
@graceful mulch dude I just told u the answer
^
why dont you tell me 🥲
When I come to know, sure :D
thankuu
@maiden fable closing Curly Bracket when?
When discord agrees that my status is good
(:
A typehint thing
Although I don't get the use for it in with commands.Bot
import typing
T = typing.TypeVar("T")
class A(typing.Generic[T]):
values: typing.List[T] = []
def set(self, *value: T) -> None:
self.values.extend(value)
def get(self) -> typing.List[T]:
return self.values
a = A[int]()
a.set(1, 2, 3, 4, 5)
quick lil example
where
why
uhmm hello?
It's not really appropriate to just respond to people with a google link, especially completely out of context
sorry
Eevee be flexing nitro
eevee doesnt have nitro...?
Wait discord broke. Before it showed that the lemon emoji was from a private server 
Breh I hate it when that happens. Discord Beta 
😨
O
😨
?
this code:
py embed = disnake.Embed(description=f"{member.mention} {str(member)}") embed.set_thumbnail(url=member.avatar.url) embed.set_footer(text=f"{member.id} | {embed.timestamp}") await channel.send(embed=embed)
Gives
Mhm
can i make the space less? i.e make the thumbnail smaller
Sure, but for that u will need to do some hackery
There's a size param
I think that should work
See
When editing the size, the image will resize. That should work
From 16 to 4096, only powers of 2 are valid
Idts, it's 100 rn and it resized
The returned size can be changed by appending a querystring of ?size=desired_size to the URL. Image size can be any power of two between 16 and 4096.
Weird, then how does 100 work 🤨
It doesn't resize to 100x100
O
Is it possible to change a guild's system channel through code?
No
Huh.. ok. Thanks. But, how do some bots do it? Give you an option as to where you want to send member join / leave notifications?
does the bot notify
!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.
or discord?
I thought about that, but not in the way I should have to see that's the answer. Thank you
“But don't forget to remove discord.py”
oh yeah, didn't notice, its not needed but disnake can do everything discord.py 2.0 can so it doesn't really matter but you could keep both of them if you want, maybe they included that because while modifying their code they might forget to replace some imports and complain something aint working and shit so yeah
@maiden fable also in the image i sent why does embed.empty come in footer?
because embed.timestamp is None
And the default value is Embed.Empty
i should have just done message.created_at
Lol
Bye
if i have a list of role ID's what's the best way to check if a member has any one of these roles? role_array_list = ["something", "something", "something","something", "something", "something"]
So u need to have the role objects for this purpose
!d any
any(iterable)```
Return `True` if any element of the *iterable* is true. If the iterable is empty, return `False`. Equivalent to:
```py
def any(iterable):
for element in iterable:
if element:
return True
return False
!d any
any(iterable)```
Return `True` if any element of the *iterable* is true. If the iterable is empty, return `False`. Equivalent to:
```py
def any(iterable):
for element in iterable:
if element:
return True
return False
;-; Why
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
True
oof i cant check for role id for member?
!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.
U will still need the role object
I would love to add that but I won't be surprised if the people in disnake server term this thing as "useless" 🤷♂️
if discord.utils.find(lambda r: r.id in list_of_ids, member.roles): # do stuff
my is_admin decorator 😔
Well that was surely useless (sorry) since there's commands.has_permissions but readability wise, that would have been a really great addition!
yeah ik i realised it later
👍
Anyone here familiar with disnake?
you want slash commands for command groups?
Very
wait so if i want to check if a member has any one of the roles from a list of role ids and if yes remove that role, i can do it with what you sent right
U will want to use :=
Walrus operator
what's that never heard of it
find returns the Role you can use remove_roles with that




