#discord-bots
1 messages · Page 640 of 1
Okay so it's like, it will assign the value to the variable inline. So,
if role := disnake.utils.get(...):
# role will be either None or the value returned by the utils.get
You may also use the walrus operator if your on python 3.8+ and you don't feel like writing an if statement
It was just an example tho
Other than that, yes the walrus is correct
Don't bulli, I am writing code on mobile rn ;-;
How do I get the bot to do this? Like have the chat bubble
I have semi good embeds for mod log/general log. What do you think
!d discord.TextChannel.trigger_typing
await trigger_typing()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Triggers a *typing* indicator to the destination.
*Typing* indicator will go away after 10 seconds, or after a message is sent.
Oh okay
now comes the boring part... the actual logging
I would have to log pretty much everything..
O
create a class for logging, it helps
Like?
what about the ```py
async with ctx.typing() #or smth very similar
i cant explain it but i have an file for it one sec
I have embed creator that I yeeted from @unkempt canyon
Yea
did I make it correctly, except the missing :?
O thanks
Yup
If your using an internal logger might as well just subclass logger and override emit to send webhooks
actually the file can be copy pasted too
but I log by embeds mostly
@maiden fable is this good?
@bot.event
async def on_member_update(before, after):
channel = disnake.utils.get(before.guild.channels, id=829046242146910215)
role = disnake.utils.get(after.guild.roles, id=803191738683621416)
role_id_list = ["something", "something", "something","something", "something", "something"]
member = after
if role in before.roles and role not in after.roles:
if role := disnae.utils.find(lambda r: r.id in role_id_list, after.role):
await role.remove(reason="User stopped boosting the server")
Also @tawdry perch make a webhook
I hate that idea but I have to accept that it is actually only working way
mind to link me the docs again?
Uhhh, I suspect the if statement gonna work tho
seemed kinda useless so i thought it would be to just do smth like that
Kinds useless? imo it's quite helpful utility
Plus you can add a Queue and wait for 10 to send at a time
Ah u referring to myxi. Thought u were talking to me
what is the docs for webhooks
looks like im thinking of something else
!d discord.WebhookAdapter
Uhhh I forgot
!d discord.Webhook
class discord.Webhook```
Represents an asynchronous Discord webhook.
Webhooks are a form to send messages to channels in Discord without a bot user or authentication.
There are two main ways to use Webhooks. The first is through the ones received by the library such as [`Guild.webhooks()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.webhooks "discord.Guild.webhooks") and [`TextChannel.webhooks()`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel.webhooks "discord.TextChannel.webhooks"). The ones received by the library will automatically be bound using the library’s internal HTTP session.
The second form involves creating a webhook object manually using the [`from_url()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Webhook.from_url "discord.Webhook.from_url") or [`partial()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Webhook.partial "discord.Webhook.partial") classmethods.
For example, creating a webhook from a URL and using [aiohttp](https://docs.aiohttp.org/en/stable/index.html "(in aiohttp v3.7)"):
ok I'll find em manuallly
There
I just send direct request to webhook
you can only send 10k requests in 10mins iirc
from discord import Webhook
import aiohttp
async def foo():
async with aiohttp.ClientSession() as session:
webhook = Webhook.from_url('url-here', session=session)
await webhook.send('Hello World', username='Foo')
``` the `url-here` means the webhook url, right?
webhook url i think
now let's see if I have permissions to create a webhooks
After that IP Ban by cloudflare
?
was this to me?
uh.. what if I don't have permissions to create a webhook, the bot might have that permission
!d discord.Webhook.from_url
classmethod from_url(url, *, session, bot_token=None)```
Creates a partial [`Webhook`](https://discordpy.readthedocs.io/en/master/api.html#discord.Webhook "discord.Webhook") from a webhook URL.
Nice
Yea
🤣
but I don't have any permissions to create a webhook, how can I get the url if it does not exist?
wait.. The bot should be able to create a webhook, right?
found it ```py
channel.create_webhook(name="mywebhook")
¯_(ツ)_/¯ if the bot has perms to do it
oh
wait...What's the role object here for the if disnake.utils.find... statement?
if role in before.roles and role not in after.roles:
if disnake.utils.find(lambda r: r.id in role_id_list, after.role):
I can get a url frrom this?
check what it returns
you dont have one
!d discord.TextChannel.create_webhook
await create_webhook(*, name, avatar=None, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a webhook for this channel.
Requires [`manage_webhooks`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_webhooks "discord.Permissions.manage_webhooks") permissions.
Changed in version 1.1: Added the `reason` keyword-only parameter.
huh... uh
That's why u use the walrus operator
:= 👌
Read this
is that new feature? i haven't use python in like 3 months but never heard of it
From Python 3.8
But it's not heavily used in daily life (that's what I noticed ngl)
💀
Oh i use it heavily
except some people
People tend to hate it though
Whyyyy. It's soooo helpful ngl
Walrus operator and typehint syntax is basically the reason why all my repo's are 3.9+
!e
if s := "h" in "hello":
print(s)
if (s := "h") in "hello":
print(s)```
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
001 | True
002 | h
keep in mind that tho
soooooo this should work right
role_id_list = ["something", "something", "something","something", "something", "something"]
member = after
if role in before.roles and role not in after.roles:
if role := disnake.utils.find(lambda r: r.id in role_id_list, after.role):
await member.remove_roles(role, reason="User stopped boosting the server")
for a webhook is the avatar needed?
Yea
I don't think so, no
good
@commands.command()
@restrict_to_user(534738044004335626)
async def create_webhook(self, ctx, name: str):
await ctx.channel.create_webhook(name=name, reason="I don't have permission to create webhook so bot made it")
``` perfect webhook
!code
you mean the first if statement? What caused it to return true?
Because h was there in hello
@slate swan you can do in #bot-commands
woopsie
in first statement what you did is
if s := ("h" in "hello"):```
Wait, what the heck is the second statement doing 🤨
!e print("h" in "hello")
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
True
so.. can I get the url of webhook name?
!d discord.TextChannel.fetch_webhook
walrus operator basically returns the thing you assign to it, by making it a tuple, you can assign exactly what you want
Ah so in the second one, in "hello" part does nothing?
!d discord.TextChannel.webhooks
await webhooks()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gets the list of webhooks from this channel.
Requires [`manage_webhooks`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_webhooks "discord.Permissions.manage_webhooks") permissions.
O Alec here
O my bad
Alec still in Halloween mood
Yea facts
if (s := "h") in "hello":```
here because its a tuple, its same as,
```py
s = "h"
if s in "hello":```
aha, thank you
i actually put the pumpkin on after halloween was over because someone said that halloween must end
Isn't the first if statement doing that?
🤣
its assigning the value of the expression which is "h" in "hello", and its value is True
And it prints True
Nipa Bot#7999 did AuditLogAction.webhook_create to <Object id=916138944969318012>
``` is it the ID of webhook?
possible
hm
hi i wanna create a bot help me
pip install discord
https://discordpy.readthedocs.io
or pip install disnake, https://docs.disnake.dev
there are some other forks as well
show error; show code
sure
!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)
no help with this
ah rip
@commands.command()
async def fetch_webhooks(self, ctx):
a = await ctx.channel.fetch.webhooks(self.web_id)
await ctx.send(a)
```so what was the correct way to get it, and how do I convert it to url
https://discordpy.readthedocs.io/en/master/api.html#discord.Client.fetch_webhook
does this mean what?
does it require smth like self.bot.fetc_webhook(id)
you can just do
!d discord.TextChannel.webhooks || webhook = channel.webhooks[channel.webhooks(index(self.web_id))
await webhooks()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gets the list of webhooks from this channel.
Requires [`manage_webhooks`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_webhooks "discord.Permissions.manage_webhooks") permissions.
something like this
actually no
im a moronic goose
webhook = [k for k in channel.webhooks if k.id = self.web_id]
@tawdry perch
discord.utils.get exists
both work
that literally does what discord.utils does
I know, no point in recreating if it already exists and does the same thing no?
🤷♂️
will it return a webhook url?
because I alrd got the webhook IDs from a 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.
I got the URL!!
!d discord.Webhook || it returns a webhook, but you can do [0].url I presume. Or you can use webhook = discord.utils.get(channel.webhooks, id=id) if the others get touchy
class discord.Webhook```
Represents an asynchronous Discord webhook.
Webhooks are a form to send messages to channels in Discord without a bot user or authentication.
There are two main ways to use Webhooks. The first is through the ones received by the library such as [`Guild.webhooks()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.webhooks "discord.Guild.webhooks") and [`TextChannel.webhooks()`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel.webhooks "discord.TextChannel.webhooks"). The ones received by the library will automatically be bound using the library’s internal HTTP session.
The second form involves creating a webhook object manually using the [`from_url()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Webhook.from_url "discord.Webhook.from_url") or [`partial()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Webhook.partial "discord.Webhook.partial") classmethods.
For example, creating a webhook from a URL and using [aiohttp](https://docs.aiohttp.org/en/stable/index.html "(in aiohttp v3.7)"):
smth's wrong with this guy
maybe they are forgetful lol
!d discord.Webhook.from_url
classmethod from_url(url, *, session, bot_token=None)```
Creates a partial [`Webhook`](https://discordpy.readthedocs.io/en/master/api.html#discord.Webhook "discord.Webhook") from a webhook URL.
I tried to pass session but it was invalid for some reason.
what did you pass?
session = session
what is your session
and session is a ClientSession?
async def send_webhook(self, embed: discord.Embed):
async with aiohttp.ClientSession() as session:
webhook = Webhook.from_url(self.webhook, adapter=session)
return await webhook.send(embed=embed)
it seems to be called adapter
But I still got this error: https://paste.pythondiscord.com/egozikomuh.sql
webhook sender that sends a embed made by embed factory
and I just managed to finish making it! (yes, fixed it smh)
damn, what exactly is broken?
Some weird piece of code is not functioning as it’s supposed to
add a lot of debugging
Debugging wasn’t working tho 😭
so it does not even get ran?
It worked on other piece of code and I tried printing it
Nothing happened so I had to email father
share the code? Tho I most likely can't help you if I have not made anything similar to it but it's worth a try I guess
my keyboard does not have a backtick on it because it's 60%. So it's easiest to get them here when I need
use #bot-commands, doing it here just annoys others
lol
It’s complicated and messy af
send anyways, maybe we can find the problem
just send it
Ok
But I don’t have my PC
but I do have a link
But I already updated it
So it’s kind of old
But I’ll send it anyways
did the updated version work? if no, then it's worth to send the old one
It did work
so it's now fixed and nothing broken anymore?
well send anyways and I can find out what you were trying in first place
Errrrr ok
Here’s the latest version of a snippet
It doesn’t execute that
res is nothing
do you happen to have a whole code of that thing?
An old version, yes
well I can take a look at the new one later
indeed a messy, bunch of statements
a bunch of imports that handles the functionality of bot that fixes a repeating parts of code
if set(message_set) & set(self.blacklisted_stuff): return await message.channel("catched something")
TypeError: 'TextChannel' object is not callable```
confused
@commands.Cog.listener()
async def on_message_delete(self,message):
if message.author.id == 218438244289740800:
self.message = '**cants snipe boot**'
self.author = message.author
message_set = message.content.lower().split()
if set(message_set) & set(self.blacklisted_stuff): return await message.channel("catched something")
self.message = message.content
self.author = message.author```
you did message.channel() that can't be called Í guess
yes
thanks
what are you going to log
https://github.com/Rapptz/discord.py/blob/master/discord/ext/commands/core.py#L541-L545, is this the method which passes the arg to the next arg if it isn't the expected type?
discord/ext/commands/core.py lines 541 to 545
if isinstance(converter, Greedy):
if param.kind in (param.POSITIONAL_OR_KEYWORD, param.POSITIONAL_ONLY):
return await self._transform_greedy_pos(ctx, param, required, converter.converter)
elif param.kind == param.VAR_POSITIONAL:
return await self._transform_greedy_var_pos(ctx, param, converter.converter)```
hoping you dont hit the rate limit of 10k requests per 10 minutes (16-17 req in one sec) tho
but i heard discord.py handles rate limits so maybe it wont be the problem
yeah, afaik it handles ratelimits automatically
Uh I will try to avoid it
apparently whenever i try making my cog and defy the cog class, there's always an issue where usually whenever i do def <cogname>(commands.Cog): it always says that commands.Cog syntax is wrong
thats not how you make a class, https://docs.python.org/3/tutorial/classes.html#a-first-look-at-classes
💀 oh
wait
im stupid af it's class not def 💀
yeah lmao
Goddammit cyberweapon
so i have 3 work commands
such as coder,gamer and artist
and i want to make a command which let the users take those work command such as
!work coder
and then they use this command and if they use !work the coder command will get trigered
and !work gamer wouldnt work for few hours
so is sql database required to store this data?
you can use cooldowns
What
yes can you tell me how do I make the author to select what work he can do?
or have you used dank memer?
Guys i'm trying to run a disnake bot, i get this error and don't understand why, someone can help?
[...]
disnake.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\giacomo.dimatteo\PycharmProjects\botDisnake\launcher.py", line 7, in <module>
bot.run(VERSION)
File "C:\Users\giacomo.dimatteo\PycharmProjects\botDisnake\botLib\Bot\__init__.py", line 77, in run
super().run(self.token)
[...]
RuntimeError: Event loop is closed
Wrong token?
Are you tryna make slash commands?
Yes
Enable the application.commands scope in your bot using the developer portal and then re-invite your bot again
there are the code and the full traceback:
code: https://pastebin.com/5QWuMZhz
traceback: https://pastebin.com/L1h5gLMW
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Strange, i don't have wrote any commands
just testing if the bot comes online
application commands == slash commands etc
hm
i don't know how to do it xD
disnake.errors.LoginFailure: Improper token has been passed.
i saw
I'm keep checking but it is correct, I checked with the debug and the os.environ get the token, i try to pass it to the bot directly
Yes, without using environ but passing the token directly it works
but why?, I already used enviroment variable and always worked
icy can you help me?
oh I resolved
print the value of it
what do you use to load env variables
python-dotenv?
!d os.getenv
os.getenv(key, default=None)```
Return the value of the environment variable *key* if it exists, or *default* if it doesn’t. *key*, *default* and the result are str.
On Unix, keys and values are decoded with [`sys.getfilesystemencoding()`](https://docs.python.org/3/library/sys.html#sys.getfilesystemencoding "sys.getfilesystemencoding") and `'surrogateescape'` error handler. Use [`os.getenvb()`](https://docs.python.org/3/library/os.html#os.getenvb "os.getenvb") if you would like to use a different encoding.
[Availability](https://docs.python.org/3/library/intro.html#availability): most flavors of Unix, Windows.
hey i have this code
def __init__(self):
super().__init__()
self.value = None
@nextcord.ui.button(label = "Aprrove", emoji=":heavy_check_mark:", style=nextcord.ButtonStyle.green)
async def approve(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if interaction.user.guild_permissions.administrator:
embed= nextcord.Embed(description=f"{suggestion}\nThe suggestion has been denied by {interaction.user.mention} message link = {message}")
channel = nextcord.utils.get(interaction.guild.text_channels,name="〢suggestion-approval" )
await channel.send(embed=embed)
self.value=True
self.stop()
@nextcord.ui.button(label = "Deny", emoji=":heavy_multiplication_x:", style=nextcord.ButtonStyle.gray)
async def deny(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
if interaction.user.guild_permissions.administrator:
embed= nextcord.Embed(description=f" {suggestion}\nThe suggestion has been denied by {interaction.user.mention} message link = {message}")
channel = nextcord.utils.get(interaction.guild.text_channels,name="〢suggestion-approval" )
await channel.send(embed=embed)
await interaction.response.send_message(embed=embed)
self.value=False
self.stop()
@client.command(aliases=["suggest"])
async def suggestion(ctx,*,suggestion:str):
view=Suggest()
embed=nextcord.Embed(title=f"Suggestion by {ctx.author.name}#{ctx.author.discriminator}", description=f"{suggestion}")
channel = nextcord.utils.get(ctx.guild.text_channels,name="〢suggest-here" )
await channel.send(embed=embed, view=view)
await view.wait()```
i want that on the reaction of the button... in the interaction response msg it shud show the users suggestion too
but this just prints out suggestion
and not the suggestion the user gave
I’m not good with formatting code
I’ve got like 60 weaknesses in my code
Spaghetti code?

any
Temporary role
Temporarily roll 💀

Create one and delete it
If you trying to do it in the same function use asyncio.sleep()

how can i see if theres a role in a server and return a true or false
Anyone know how to make bot reply prefix when pinged I tried in js but it ain’t working
Be good then 💯
if len(guild.roles) > 1:?
Anyone know how to make bot reply prefix when pinged I tried in js but it ain’t working
!d discord.ClientUser.mentioned_in
mentioned_in(message)```
Checks if the user is mentioned in the specified message.
just do an on_message and if the context is "prefix" then message.reply("thing")
or that
thats more efficient
Ok
Smort
scrap that question, how can I see if a specific role has admin for example
@vague grove @visual island thx
yeye
if role.permissions.administrator:
and could you say role = "test"
guild.
k
I got the error Command raised an exception: AttributeError: 'NoneType' object has no attribute 'permissions'
my code is
@client.command()
async def role(ctx):
role = ctx.guild.get_role("test!")
if role.permissions.administrator:
print("admin")
else:
print("No admin.")
you can't compare a role object to a string, if you wanna do that you'd have to compare it by the name
get_role needs an ID, not a string
im guessing theres a line of code where you can fetch the id from the string
!d discord.utils.get
discord.utils.get(iterable, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/master/api.html#discord.utils.find "discord.utils.find").
When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.
To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.
If nothing is found that matches the attributes passed, then `None` is returned.
Examples
Basic usage...
yes
which is ;]
🤬🤬🤬
@vague grove
How do you copy text using like a command like the bookmark command in sir Lancebot
💀
wasnt that to fetch the role itself, which needs an id?
!d discord.Message.content
The actual contents of the message.
No, you can use that to fetch the role by name also
.bm
alright, I'll try later on, for now I got to go
thank you for the help so far.
👍

You welcome
Thanks…..
.

where can I find list of all events, such as on_member_join and well a list of events
Errr
discord.py has an extensive collection of features. Events are one of the most useful of these. Event...
it only has few of them
what else should I log, I have these so far https://paste.pythondiscord.com/zedugugeqa.py
can someone show me an example of bot.wait_for('add_reaction')
There's one in the docs
!d discord.ext.commands.Bot.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
click the title
I think this is enough to log, right?
Lemme see
it's just a function
fk
i want it to check if the person adding the reaction is the same person who triggered the command(msg.author)
otherwise it's good?
how do i refer to the person adding a reaction?
lambda user, reaction: user == ctx.author
@tawdry perch don't send on reaction add
I forgot to remove it
That.... just doesn't make any sense ngl
Hey BTW, I have another idea
(Sorry Diabolical I am stealing yours here)
Just send a message in another channel instead of logs whenever a person boosts a server
on_guild_update is triggered when the number of server boosters change right?
wym?
what does the lambda user at the beginning mean?
Yea
Whenever someone boosts the server, send a message?
ah ok
i've used bot.wait_for for 'message' before but how do i change it for add reaction?
Well I guess boost a guild yourself and see it
sure, let me just buy a nitro for that
i need to know the reaction added and the person who added it
Well none of us really tried ngl
Hahaha
now time to design fricking log messages ;-;
I have embed builder alr
classmethod from_dict(data)```
Converts a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") to a [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") provided it is in the format that Discord expects it to be in.
You can find out about this format in the [official Discord documentation](https://discord.com/developers/docs/resources/channel#embed-object).
content = await self.modlog.send_log_message(
self, colour=discord.Color.red(), title=f"{member} | {member.id} has joined",
text="", icon_url=member.avatar_url,
content="Sample content", footer="Logger webhook", ping_everyone=True
#thumbnail="Sample thumbnail"
)
await ModLog.send_webhook(self, content)
``` this sends a embed, and a webhook for me (indent fked up)
O
Mhm
@bot.command()
async def gamer(ctx):
await ctx.send('You have 2 Choices \n(A)A Baseball Bat With Iron Wires Coverd\n(B)An M16 With 90 Bullets\n what will you choose?')
channel = ctx.message.channel
player = ctx.author
gg = random.randint(100, 150)
wala = random.randint(50, 100)
def nocheck(m):
return m.content == "(B)" or 'b' or 'B' or '(b)' and m.channel == channel
if msg = await bot.wait_for('message', check=nocheck)
await ctx.send(f"You aint a real gamer and dont understand fun it but then to got **{wala}:nexus:**")
def check(m):
return m.content == "A" or m.content == '(A)' or m.content == "a" or m.content == "(a)" and m.channel == channel
else msg = await bot.wait_for('message', check=check)
c.execute(f"UPDATE data SET balance = balance+{gg} WHERE ID = {player.id}")
conn.commit()
await ctx.send(f"You Are A Real Gamer **{gg}:nexus:** as Gift From Every Gamer")
print(gg)
syntax error if msg =
help pls
= is not a comparison operator if you meant to compare them
Missing a =
The comparison operator is ==
Although that's not how it works
so i gotta do
if = msg
or
if:
msg
so im tryna make a selection out of 5 reactions and have bot know what i selected
im using bot.wait_for('reaction_add'.......
and this is my check
def check(reaction, user):
return user==msg.author and reaction.message == expired_queue and reaction.emoji in ["1️⃣", "2️⃣","3️⃣","4️⃣","5️⃣"]
but it never triggers TwT
like dis?
if msg:
await ctx.send(f"You aint a real gamer and dont understand fun it but then to got **{wala}:nexus:**")
def check(m):
return m.content == "A" or m.content == '(A)' or m.content == "a" or m.content == "(a)" and m.channel == channel
msg = await bot.wait_for('message', check=check)
else:
player = ctx.author
gg = random.randint(100, 150)
c.execute(f"UPDATE data SET balance = balance+{gg} WHERE ID = {player.id}")
conn.commit()
await ctx.send(f"You Are A Real Gamer **{gg}:nexus:** as Gift From Every Gamer")
print(gg)```
awkward noises I was kidding
no but seriously you know whats wrong?
its highlighting elif as syntax error
i'm blind, where's the elif
my bad i mean else
is the indentation correct?
hmm, where's the c coming from?
syntax highlighting else
okay where is the c now i am blind as well
c.execute
its a sql variable
mhm I see
its defined as global variable beacuse its an economy bot
Your indentation
try using exceptions
does anyone know how to make timestamp markdown in short date/time?
everything inside the function lmao, didnt even notice
There's a style kwarg
But I did (:
but then why its saying else as syntax error
huh where?
I'm blind
!d discord.utils.format_dt
discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.9)") for presentation within Discord.
This allows for a locale-independent way of presenting data using Discord specific Markdown...
Nahhh
I'm an old woman now, I need glasses xD
can i put markdowns in the embed footer?
An else statement without an if one. Yikes 😬
No
is it because he doesn't have an "if" in the function "check"?
oof
🤦♂️
you are more blind then eeve
look at the first word
😐
this....?
hmm okay i will try making the function outside
It's out of the indent....?
no I'm not sure about it
idk i copied it and pasted in discord and its coming like dis
Notice anything?
have you read it in the first place?
🤣 I found the mistake
And yea, a suggestion
Learn again about if statement and functions before continuing
That has to be the ugliest indentation I’ve ever seen in my life.
U r defining a function after the if statement and after that an else block that too with wrong indent 😐
what kind of thumbnail would be good for log embeds?
how do i get the short date/time format? like one of the styles for markdown is <t:unix>
does anyone know?
timestamp unit?
veri nic3
If u mean keeping line length till 80 words or something, then nope
like dis?
can you send a example of what you mean
sometimes I don’t follow that part either also it’s 79 characters
nvm got it
oh cool
but fr, what would look good for it?
Seriously, a brown cartoon log with green background would be damn cool
sigh
lmaooo
No cap
;-;
agreed
how do i get the unix for a message.created_at object?
i'll save you copyright issues
do you have a converted for that by any change? smth like this
what?
oh you mean converter?
ye 😅 (just in case you need to do it many times)
nope i do not
import datetime
import time
datetime = datetime.datetime(2020, 2, 11, 10, 20)
print("Unix_Time_stamp: ",(time.mktime(datetime.timetuple())))
``` as example this might be what you are looking for?
but how do i make a message.created_at return object into unix so i can use markdown timestamp
oh return it to object, ehh then I don't know sorry
@maiden fable any idea please?
this is off topic this channel. Consider looking at datetime docs since created_at() returns a datetime object.
It returns a datetime.datetime object, hmmmmmm
!d discord.Message.created_at
property created_at: datetime.datetime```
The message’s creation time in UTC.
O
round()
Round()?
you sure?
I’m not sure about that one
I thought round was inaccurate
That’s for floats
Hai tylerr
!e ```py
import time
import datetime
d = datetime.date(2015,1,5)
unixtime = time.mktime(d.timetuple())
print(unixtime)
!e print(round(2.5))
@velvet tinsel :white_check_mark: Your eval job has completed with return code 0.
2
See it’s inaccurate
Ah got it
@cloud dawn :white_check_mark: Your eval job has completed with return code 0.
1420416000.0
@velvet tinsel :white_check_mark: Your eval job has completed with return code 0.
3
At least THAT works
For what?
You could use ceil
@spring flax
what's that?
A bot Hunter made
The unix
message.created_at.timestamp() returned the unix timestamp @spring flax
I’m having trouble doing something like that 
Its a simple eval tho
You can pass the modules in eval if you want even variables and functions.
You do use exec

What are you doing?
Eval code
I have no idea what that means and where you are stuck on.
!e import hello
@velvet tinsel :white_check_mark: Your eval job has completed with return code 0.
Hello world!
!e exec("import hello")
@cloud dawn :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | File "<string>", line 1, in <module>
004 | ModuleNotFoundError: No module named 'hello'
!e exec("print(“hi”)")
@velvet tinsel :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | File "<string>", line 1
004 | print(“hi”)
005 | ^
006 | SyntaxError: invalid character '“' (U+201C)
!e exec("print() ")
@velvet tinsel :warning: Your eval job has completed with return code 0.
[No output]
It prints it but i can’t store in a variable
!e exec("print(somevar)", {"somevar": "hey"})
@cloud dawn :white_check_mark: Your eval job has completed with return code 0.
hey
exec(object[, globals[, locals]])```
This function supports dynamic execution of Python code. *object* must be either a string or a code object. If it is a string, the string is parsed as a suite of Python statements which is then executed (unless a syntax error occurs). [1](https://docs.python.org/3/library/functions.html#id2) If it is a code object, it is simply executed. In all cases, the code that’s executed is expected to be valid as file input (see the section [File input](https://docs.python.org/3/reference/toplevel_components.html#file-input) in the Reference Manual). Be aware that the [`nonlocal`](https://docs.python.org/3/reference/simple_stmts.html#nonlocal), [`yield`](https://docs.python.org/3/reference/simple_stmts.html#yield), and [`return`](https://docs.python.org/3/reference/simple_stmts.html#return) statements may not be used outside of function definitions even within the context of code passed to the [`exec()`](https://docs.python.org/3/library/functions.html#exec "exec") function. The return value is `None`.
!source eval
Run Python code and get the results.
Change the code..?
redirect_stdout
!d contextlib.redirect_stdout
contextlib.redirect_stdout(new_target)```
Context manager for temporarily redirecting [`sys.stdout`](https://docs.python.org/3/library/sys.html#sys.stdout "sys.stdout") to another file or file-like object.
This tool adds flexibility to existing functions or classes whose output is hardwired to stdout.
For example, the output of [`help()`](https://docs.python.org/3/library/functions.html#help "help") normally is sent to *sys.stdout*. You can capture that output in a string by redirecting the output to an [`io.StringIO`](https://docs.python.org/3/library/io.html#io.StringIO "io.StringIO") object. The replacement stream is returned from the `__enter__` method and so is available as the target of the [`with`](https://docs.python.org/3/reference/compound_stmts.html#with) statement:
```py
with redirect_stdout(io.StringIO()) as f:
help(pow)
s = f.getvalue()
``` To send the output of [`help()`](https://docs.python.org/3/library/functions.html#help "help") to a file on disk, redirect the output to a regular file...
!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.
!e
import code
i = code.InteractiveInterpreter(locals=dict(hi="hello world!"))
hi = i.runsource("print(hi); lol = 5")
print(i.locals["lol"])```
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
001 | hello world!
002 | 5
is that what you want
whoa, that's new
how do i make an if message.content triggered only in a specific channel
if message.channel.id == id:
oh
This looks so much cleaner i have like 5 imports to make the damn eval work lol.
.bm
.bm
I like how the beginners bios are like: “DM for bot I’m a dev” while the helpers bios are like “oh no exams” or “I like coding”
Oh gosh i have a exam tomorrow 
I like programming 
Im not joking i have a exam tomorrow 😭
I’m not jokingni like programming 😭

Science
I love science
Computer science? Yeah 
No general science

But…meh
Computer science is my favourite science
What’s your favourite science 

Biology 
About rocks🤬
That’s geography
No bruh
Cells 🤬
Types of rocks🤬
It’s simple af
Lovely
Sedimentary, igneous…I forgot the other one 💀
I want it to be mine except they teach Java
Metamorphosis
Your brain is also a rock
Oh RIP 💀 I hope I can do rust
🤬🤬
They worship Java for some reason
Metamorphic
Im gonna take computer stuff in 10th grade but idk what they teach
Is the other type of rock
I’m taking IB in sixth form but they don’t do computer science
Hah, I remember my sophomore year comp sci, quite boring
They always say its old but "gold"
Such a nice pun, I’m laughing right now
Java is overdue tbh
*overrated and so is python actually
I mean it taught me the sorting algorithms but that’s about it
i like rust, its beautiful
My school should have a python curriculum, but I think they teach that in higher years
Its probably gonna be boring like talking about usbs or something i would love to learn about js thats all cause i know about hardware and other stuff related to technology
It’s all just JavaScript these days
Like freecodecamp
I need to take a lesson on rust
but I don’t have time so I’m thinking after finishing my bot
: |
I think js is gonna takeover no jk

🤦♂️
I hope 
I’ve seen libraries in the most obscure languages, why not for something relatively mainstream like rust haha
The thing about other languages are you have to make a class or a function in order to execute code, it’s annoying
Rust isnt good at all
In python you just execute it
Try php
Then go for functional languages like Haskell
🤬🤬
rust has workarounds for function decorators like python so even if it doesnt have one, you can make your own
🤬🤬
Off-topic channels
There are three off-topic channels:
• #ot2-never-nester’s-nightmare
• #ot1-perplexing-regexing
• #ot0-psvm’s-eternal-disapproval
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
🤬
well its been the most loved language for more than 4 years :|
Ik its a joke lmao
most of them dont care about block indentation, you can make it gone, or even make an extension for your ide (maybe some already exists) to make it disappear
https://discordpy.readthedocs.io/en/latest/api.html#discord.Message.clean_content
how do i access this class helper when doing
post = "hi @everyone"
await ctx.send(post)
Tbh i like indentations as you know that your code is well done
Must be shitposting right now
just use flask for backend pl0x. no php.
||i think you forgot its a joke||
You’re all forgetting bf is the best language
Nah English is the best language
Guess I didn’t notice 
Like not the speaking language the actual programming language
Fair point

Though Python is like speaking English so therefore Python is the best language
Anybody know whos zyapguy?
I’ve seen some of his videos but other than that not really
Hes funny ngl
Yee
Hello
👋

@sick birch you should watch his new video i think its talking about not known languages and its actually really funny
Haha I’ll check it out when I’m back from school
The questions bro😭
Stackoverflow is a bit of a cesspool imo lmao
“Switch to a real programming language”
I hate these responses
Bro he searches for questions in stackover flow and people make questions but people respond with stupid answers like:
print("hi')
Why isnt this working anybody help
Peoples response:
learn java
Yeh
I see stuff like that a lot in help channels, here or even on stack overflow, you want to fix B but someone suggests do A
😭
Yeah😭
Stack over flow is just alot of java robots
Ikr
What language should i start?
Always C
Java or c++
People: Start with JAVA and C++
😭
At least C is ok Java is just meh
🙃
Overdone to hell
Whateheck
"Learn a real language and not a kids language like python learn java or C its not that hard"
"Java is the best language"
"Omg very tru"
"PHP ITs the bEzt Languege"
😭
"ruBy is Bezt Languaege
Ruby isnt that bad ig🤷♂️
oke its just a joke
sys.stdin? or smth like that afaik
Console.log("Hello world"):
Python moment
anyways, wish me luck I will be putting a lot of embeds logging
😭
Goodluck g
Good luck bro
You edited the message and you put ":"
GUD LUK BRO
I tried this at my python and it works for some reason
Cursed
It's brocken
; are cringe watfk
Bruh
!ot @slate swan @plush cosmos
Off-topic channels
There are three off-topic channels:
• #ot2-never-nester’s-nightmare
• #ot1-perplexing-regexing
• #ot0-psvm’s-eternal-disapproval
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
Love your pfp mr.hecker
Thank ya
this isn't a general chat, let's keep the topic on discord bots please
on_bulk_message_delete how can I find the amount of bulked messages?
My bad i was just being polite
not just that message, look above it
Yeah that too
😐
!d discord.on_bulk_message_delete len ig
discord.on_bulk_message_delete(messages)```
Called when messages are bulk deleted. If none of the messages deleted are found in the internal message cache, then this event will not be called. If individual messages were not found in the internal message cache, this event will still be called, but the messages not found will not be included in the messages list. 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_bulk_message_delete()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_bulk_message_delete "discord.on_raw_bulk_message_delete") event instead.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Isn't that what mods are for
hmm
oh it's messages
yes
ah, let me load the cog and see what happens
how may I get the channel those messages been bulked in at?
U can do messages[0].channel
Since the messages would be deleted in the same channel
ah
I did ```py
@commands.Cog.listener("on_bulk_message_delete")
async def bulk_alert(self, messages):
content = await self.modlog.send_log_message(
self, colour=discord.Color.red(), title=f"Alert",
text=f"({len(messages)}) messages have been bulked in {messages[0].channel}", icon_url=discord.Embed.Empty,
footer="Logger webhook"
)
await ModLog.send_webhook(self, content)
there was 6 messaged being purged
Yea
discord.on_raw_bulk_message_delete(payload)```
Called when a bulk delete is triggered. Unlike [`on_bulk_message_delete()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_bulk_message_delete "discord.on_bulk_message_delete"), this is called regardless of the messages being in the internal message cache or not.
If the messages are found in the message cache, they can be accessed via [`RawBulkMessageDeleteEvent.cached_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.RawBulkMessageDeleteEvent.cached_messages "discord.RawBulkMessageDeleteEvent.cached_messages")
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Lol
depends
no?
who said that smh
i mean, it does break it technically
ig yes
low chance it'll be taken down afaik
!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)
Old tutorials which some use ytdl which is against tos
how can I get permissions of a role in channel?
!d discord.TextChannel.permissions_for
permissions_for(obj, /)```
Handles permission resolution for the [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role").
This function takes into consideration the following cases...
ooo
Spotify and others,they have to be non copy right or you'll break copyright laws
how do you memorize all of this ;-;
hey
hi
@bot.command()
async def gamer(ctx):
await ctx.send('You have 2 Choices \n(A)A Baseball Bat With Iron Wires Coverd\n(B)An M16 With 90 Bullets\n what will you choose?')
channel = ctx.message.channel
player = ctx.author
gg = random.randint(100, 150)
wala = random.randint(50, 100)
def check(m):
return m.content in ("A", '(A)', "a", "(a)") and m.channel == channel
def nocheck(m):
return m.content == "(B)" or 'b' or 'B' or '(b)' and m.channel == channel
msg = await bot.wait_for('message', check=check)
if msg:
await ctx.send(f"You Are A Real Gamer **{gg}:nexus:** as Gift From Every Gamer")
else:
msg = await bot.wait_for('message', check=nocheck)
await ctx.send(f"You aint a real gamer and dont understand fun it but then to got **{wala}:nexus:**")
the bot is not responding when i typed 'b' or (b) or B or (B)
just responds to a
all mods hate me
I am a mods biggest nightmare
💀
inserts !ot
help pls
If hunting the Hunter: print(“!ot”)
What’s the problem
There shouldn’t be a dot
Where?
Oh
Hai Okimii 😐
if hunter == hunter:
await ctx.send("!ot")
😳
🤬
😳
Uhhh
I regret being a helper now
Im not gonna even answer that i hate reading long code in mobile
Me no like big code on mobile
But I’m just going to say wait_for()
@slate swan no comment

sad
its alr
Just this
@commands.command()
async def get_permissions(self, ctx, role: discord.Role):
a = ctx.channel.permissions_for(role)
print(a)
``` why this be incorrect?
What’s the error
we all know you dont know about this
Oh I forgot to add it ;-;
🚐💀🤦♂️
hmm but i am using that
mom runing towards you to beat your a$$
Your phone fell on itself?
Yes
I meant floor 😭
okimil can you help me with this?
thats why i have tempered glass on my phone
oh
Got a nokia so no need
nice
anyone?
Im not worried that my phone will break im worried the floor will
if msg why are you doing that? its always going to be True
😂
rip floor
Poor floor
🤬 
oh so i gotta do
if msg = msg:?
msg is the discord.Message you were waiting for. what do you think you're doing in that if statement?
Wish I also knew 😐
hjelp me to get the permissions from channel, if you happen to know
No
Yes
Wym
You need a text channel instance
I got it
tbh idk
someone told me to use if statement
and passed role to it
ctx.channel.permissions_for(ctx.guild.roles[1])
what do you want to do
and was like alr just add if and else and start pressing spaces and tabs
@commands.command()
async def get_permissions(self, ctx, role: discord.Role):
a = ctx.channel.permissions_for(role)
print(a)
``` why can't I just do this?
U can do that also
BTW
not in this way tho
ctx.permissions_for() would also work
so i want to make a command
!gamer
bot gives 2 options
if user types A then the bot will run a function if B then another function
https://paste.pythondiscord.com/lijikamano.sql I don't think I can
Huh? Lemme try that
Yay not break
in the check, check if the message content is in a list of strings, where each string would be the options
later either use match-case(py310) or if-elif to check the exact message content
but I can't do this?
like dis?
return m.content in ("A", '(A)', "a", "(a)") and m.channel == channel```
yes
You surely can tho
How r u using the command?
!get_permissions <id_of_role>
i have dis
def good(m):
return m.content in ("A", '(A)', "a", "(a)") and m.channel == channel
def wrong(m):
return m.content == "(B)" or 'b' or 'B' or '(b)' and m.channel == channel```
merge them
merge?
if m.content in (a,b,(a),(b))
sure
same error
look at the full code (just in case)
@bot.command()
async def gamer(ctx):
await ctx.send('You have 2 Choices \n(A)A Baseball Bat With Iron Wires Coverd\n(B)An M16 With 90 Bullets\n what will you choose?')
channel = ctx.message.channel
player = ctx.author
gg = random.randint(100, 150)
wala = random.randint(50, 100)
def good(m):
return m.content in ("A", '(A)', "a", "(a)") and m.channel == channel
def wrong(m):
return m.content == "(B)" or 'b' or 'B' or '(b)' and m.channel == channel
msg = await bot.wait_for('message', check=good)
if msg:
await ctx.send(f"You Are A Real Gamer **{gg}:nexus:** as Gift From Every Gamer")
else:
msg = await bot.wait_for('message', check=wrong)
await ctx.send(f"You aint a real gamer and dont understand fun it but then to got **{wala}:nexus:**")
Tf??? Lemme try your code
why are you waiting for two messages
@bot.command()
async def get_perms(self, ctx, role: discord.Role):
a = ctx.channel.permissions_for(role)
await ctx.send(a)
ohh
i didnt knew i can use 1 bot.wait_for for 2 ctx.send
looks like you're really confused what you are even doing
I did that, right?
at this point, just delete the entire code and code it again
by yourself
Lemme see
because its wrong
oh
oh and did that work for you?
okay thats a good idea ty
wtf
oof
explain me
What?
how did it work for you
Any who can help me with music bot
The code is right in front of u... Could be a discord bug which got fixed in disnake?
!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)
im making one but I ran into an error
But my play command dont work
🤷♂️ No help since it's against ToS, sorry
so I did it correctly but it still did not work..?
Can u send me code
Seems like it, yea
;-;
Try using disnake?
Why tho
im running into an error
because I'm not yet done for a move
I will try to fix
@slate swan we can't help you with music bots
Ok sry
Everything is same, u just change imports from disnake to disnake tho
!rule 5 to be specific
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
Or u can also do import disnake as discord
but it will mess up with dpy lib.. (if imported as discord)
Ah, then just change imports?
Which ide u using?
vsc
even notepad has find and replace feature
too much of work for just a 1 command to work
CTRL Shift F and select all the instances of discord to disnake after selecting everything with CTRL D
I'll try to find another way to fix the code
Well your wish 🤷♂️
As I said, it seems like a discord.py issue ngl
I tried your code, literally in front of u and it works perfectly on disnake
Same it really doesnt give a error
Disnake gets access by disnake and dpy gets accessed by discord so really shouldn't raise a error
Facts
gib command to install disnake as discord
import disnake as discord
You can do this but its bad practice
what is the better way
pip install disnake ["discord "] iirc
But uninstall discord.py then
Replace discord with disnake manually




