#discord-bots

1 messages · Page 651 of 1

slate swan
#

You don't because streaming music from Spotify is against their Terms of Service

boreal ravine
#

playlist function meaning?

quaint epoch
#

guys what is the syntax for muting channels using this servers python bot?

#

*hushing channels

fast spear
boreal ravine
#

ah

unkempt canyonBOT
#
Command: silence

Silence the current channel for duration minutes or forever.

Source Code
placid skiff
#

Someone?...

quaint epoch
#

How do I mute vc's?

#

what guild commands would i use?

boreal ravine
#

this channel is for discord bots

#

ask somewhere else smh

placid skiff
#

Lol the project is for a discord bot

#

And technically i could ask anywhere, it is a python problem, doesn't have any categories

placid skiff
#

It is a function which is called and return a TypeError, it is not relationed to what i'm doing

boreal ravine
#

hm

placid skiff
#

well it is not like that the function returns TypeError, the call of the function returns a TypeError which is different lol

#

I have the same script used to another project and it works fine

quaint epoch
#

What feature would be useful for moderation?

#

features*

tawdry perch
#

anti spam

quaint epoch
#

Doesn't discord already have an anti-spam?

#

or i could use slow-mode?

tawdry perch
#

also some of these might be helpful, + anti raid

tawdry perch
quaint epoch
#

okay

boreal ravine
quaint epoch
#

how do i dm ppl using my bot?

boreal ravine
unkempt canyonBOT
#

await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
tawdry perch
quaint epoch
tawdry perch
#

ahh it's used to add roles to member

#

not really useful*

rare saddle
#

Why a mistake?

boreal ravine
#

having 2 commands for this is kinda dumb

tawdry perch
#

1 is for removing and second one is or adding, I don't want to mess too much with the old code

boreal ravine
#

¯\_(ツ)_/¯

tawdry perch
#

for some reason when someone sends a message to server 1 more of the logging gets added, I have been trying to find it but no luck so far. I have searched every file so many times.. it is getting annoying.

#

I'm so good that I don't even remember when i added that ;-;

tawdry perch
#

Just saying, because I was bored and the chat was not too active

quaint epoch
#

so i don't go anywhere near to csv reading/parsing

tawdry perch
#

weird

quaint epoch
boreal ravine
#

Do people not get tired of creating bots, like every new bot is the same

quaint epoch
#

how do i mute a vc?

#

or an entire role in a vc?

#

either will do

tawdry perch
boreal ravine
tawdry perch
#

I was making my own API

quaint epoch
#

i ALWAYS got 429s, or 500s when i requested json data

quaint epoch
#

🤷

tawdry perch
#

lemonapi (kinda done, missing a commit)/chatapp (under development)

wooden thorn
#

How do I make my bot detect if it's already in a voice channel?

quaint epoch
#

i don't try and scrape data off of reddit anymore

tawdry perch
#

both of them are in github

quaint epoch
boreal ravine
unkempt canyonBOT
#

class discord.VoiceClient```
Represents a Discord voice connection.

You do not create these, you typically get them from e.g. [`VoiceChannel.connect()`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceChannel.connect "discord.VoiceChannel.connect").

Warning

In order to use PCM based AudioSources, you must have the opus library installed on your system and loaded through [`opus.load_opus()`](https://discordpy.readthedocs.io/en/master/api.html#discord.opus.load_opus "discord.opus.load_opus"). Otherwise, your AudioSources must be opus encoded (e.g. using [`FFmpegOpusAudio`](https://discordpy.readthedocs.io/en/master/api.html#discord.FFmpegOpusAudio "discord.FFmpegOpusAudio")) or the library will not be able to transmit audio.
boreal ravine
#

^^ dont think thats accurate tho

tawdry perch
quaint epoch
gentle rose
#

Why do i get AttributeError: module 'discord.guild' has no attribute 'default_role'?

channel.set_permissions(discord.guild.default_role, send_messages=False)
boreal ravine
quaint epoch
gentle rose
quaint epoch
#

Then do py Guild.default_role

gentle rose
boreal ravine
prisma spoke
boreal ravine
prisma spoke
#

Posting the question again

quaint epoch
#

or maybe in the params usepy async def hi(ctx, guild : Guild)

quaint epoch
#

shit i forgot to include ctx

gentle rose
prisma spoke
boreal ravine
prisma spoke
quaint epoch
prisma spoke
prisma spoke
quaint epoch
#

I searched up synonyms for warn

tawdry perch
#

discord.member.Member?

quaint epoch
#

i could've done discord.Member

#

but i did it that way

prisma spoke
tawdry perch
prisma spoke
prisma spoke
quaint epoch
prisma spoke
proven vigil
#

no

prisma spoke
#

There's nothin as discord.member.Member

quaint epoch
#

huh, they did for me

prisma spoke
quaint epoch
prisma spoke
#

@quaint epoch learn python plz

prisma spoke
quaint epoch
prisma spoke
#

There's nothin as discord.member.Member

proven vigil
quaint epoch
boreal ravine
prisma spoke
slate swan
# prisma spoke There's nothin as discord.member.Member

Umm there is...
discord.member.Member means the Member class in member file in discord directory...
Why discord.Member works is because in the init file located in discord, Member object is imported so that you don't need to write whole path again and again

proven vigil
prisma spoke
#

WHATTTT

quaint epoch
#

there is also this, they did the same things for me

boreal ravine
#

discord = folder, member = file name, Member = class name 🤦‍♀️

slate swan
#

Both are SAME things... Why to make an argument over it lol

prisma spoke
quaint epoch
#

but why is there discord.member.Member then?

boreal ravine
quaint epoch
#

if there is discord.Member

prisma spoke
boreal ravine
proven vigil
prisma spoke
quaint epoch
slate swan
boreal ravine
#

what dont you get

slate swan
boreal ravine
#
#discord/member.py

class Member:
    ...
``` smh
quaint epoch
#

well both of them work

proven vigil
quaint epoch
boreal ravine
proven vigil
#

me too

quaint epoch
#

it doesn't matter i'm going to abuse the power of my bot and warn ppl for no reason

spark kite
#

can someone help me send a dm?
I looked at the python api faq and just switched their code so it used my own user id instead but I keep getting an error.

prisma spoke
proven vigil
#

await member.send()

slate swan
#

Anyways what was the main issue lol?

prisma spoke
#

Cuz u r not storing the warna

boreal ravine
spark kite
prisma spoke
proven vigil
#

check if it's written correctly

prisma spoke
gentle rose
#

Which permissions do i need to change if i want to change Permissions to write for everyone role in guild?
currently i get this error: discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

quaint epoch
slate swan
#

!d discord.abc.Messageable.send

unkempt canyonBOT
#

await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
quaint epoch
#

just enter a valid user

slate swan
boreal ravine
quaint epoch
#
member = discord.Member(# int here)
await member.send(content=(stuff to send))```
slate swan
bold surge
prisma spoke
boreal ravine
prisma spoke
quaint epoch
# boreal ravine Fetch the member

haha jokes on you i enabled members intent and admin but i can't fetch members because I HAVEN'T ENABLED MEMBERS INTENT APPARENTLY

prisma spoke
slate swan
proven vigil
#

Search for intents

prisma spoke
#

It has comments cuz I used pillow and I had to create the bar and all

proven osprey
#

guys i have a problem help me please

boreal ravine
slate swan
#

use Bot, Client don't use this commands extension

#

did u define client ?

boreal ravine
#

!d discord.ext.commands.Bot use this

unkempt canyonBOT
#

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.
gentle rose
boreal ravine
slate swan
boreal ravine
spark kite
quaint epoch
#

did you do py client = discord.ext.commands.Bot(command_prefix='prefixhere')

spark kite
#

im not sure why

prisma spoke
slate swan
prisma spoke
quaint epoch
slate swan
#

I mean where you declared your "client" thing, use commands.Bot instead of discord.Client

prisma spoke
#

Bruh

#

Wth

slate swan
#

No need to declare both

prisma spoke
#

Using 2 variables?

boreal ravine
slate swan
#

just Bot will work fine

spark kite
# quaint epoch what's the error?
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 70, in on_ready
    member = discord.Member(646136875282595871)
TypeError: __init__() takes 1 positional argument but 2 were given

quaint epoch
#

other way around

quaint epoch
slate swan
#

discord.Member is the class

#

You don't create discord.Member classes manually

#

you need an instance

boreal ravine
rare saddle
#

How to make sure that the buttons do not stop working until the bot is restarted?
Library - dislash

slate swan
#

bot.get_user(id) if you ahve intents, await bot.fetch_user(id) if you don't

slate swan
#

you clearly don't know what you're doing

polar ice
#
    embed.set_footer(text="NOTICE: Please be patient, our staff will assist as soon as they are available.")
    embed.set_thumbnail(url=logo_url)
    msg = await ctx.send(embed=embed,components=[Button(label="Open Ticket", custom_id="ticket", style=ButtonStyle.green)])

Hello sorry for the newb question. im just looking into buttons for the first time. Ive created a button but how do i then detect when its been clicked?

#

im using discord-components

slate swan
#

why are you using that shit lib

#

and not dpy 2.0

polar ice
#

i was using dpy 2.0 but i got recommended this. Cant seem to get either of them working 😦

quaint epoch
spark kite
slate swan
prisma spoke
slate swan
#

be consistent

shadow wraith
slate swan
# prisma spoke Huh? Why?

because consistency, and naming it client when your bot is a commands.Bot instance is just confusing

shadow wraith
#

im just used to []

quaint epoch
slate swan
prisma spoke
slate swan
slate swan
boreal ravine
slate swan
#
client = discord.Client()  # CORRECT
bot = discord.Client()  # WRONG

client = commands.Bot()  # WRONG
bot = commands.Bot()  # CORRECT
shadow wraith
prisma spoke
#

Then rank=

boreal ravine
shadow wraith
#

oh

boreal ravine
#

just the variable naming is wrong

shadow wraith
#

srry

prisma spoke
gentle rose
#

How to set this send permission rule timed? I want to set send_messages to False after 15 minutes for example
my code:

await channel.set_permissions(reaction.message.guild.default_role, send_messages=True)
shadow wraith
#

i only came here for command ideas 🚎

boreal ravine
prisma spoke
boreal ravine
#

yes

shadow wraith
#

go for a cycle and do import asyncio then convert on google how much is 15 minutes into seconds

slate swan
shadow wraith
#

then do ```py
blahblahblahblah
await asyncio.sleep(...)
blahblahblahblah

slate swan
prisma spoke
boreal ravine
boreal ravine
gentle rose
prisma spoke
#

Why two.variables?

gentle rose
prisma spoke
#

Remove client=discord.Client

boreal ravine
sage otter
#

I mean you could just use Loop.call_later()

slate swan
#

wait what , why are you using both bot and client lmao

prisma spoke
shadow wraith
#

didnt know that sorry :

shadow wraith
slate swan
prisma spoke
shadow wraith
#

idk

slate swan
shadow wraith
#

im only here for command ideas

slate swan
#

its pretty enjoyable tbh

boreal ravine
prisma spoke
slate swan
prisma spoke
slate swan
#

whats wrong ?

boreal ravine
boreal ravine
boreal ravine
slate swan
#
whatever = commands.Bot(command_prefix=)```
boreal ravine
#

this is why you got banned from tcr 🤦‍♀️

slate swan
prisma spoke
prisma spoke
#

Got ur answer?

slate swan
boreal ravine
prisma spoke
prisma spoke
#

505*

rare saddle
#

Why a mistake?

prisma spoke
boreal ravine
quaint epoch
prisma spoke
prisma spoke
#

Based on how u coded

quaint epoch
boreal ravine
quaint epoch
prisma spoke
quaint epoch
#

It practically dead anyway

boreal ravine
slate swan
#

@prisma spoke

  • Check if the users you were testing with have same xp or not...
  • Try to print rank getting outputted from the db. The issue might be in creating rank card too.. who knows
prisma spoke
prisma spoke
#

How will the issue be in generating the card?

#

I even printed the result and it gave as a tupe with value 0

slate swan
#

Idk. Your rank card create function is already cursed. So I just assumed so

prisma spoke
slate swan
#

Make a general function and then use if else.. No?

prisma spoke
prisma spoke
#

Are

slate swan
#

Nevermind there are still ways you can shorten your code but it's not the real issue

prisma spoke
#

Anyone else?

slate swan
shadow wraith
#

hey what theme is that

slate swan
#

Vscode with github theme

shadow wraith
#

dimmed or

#

whats the github theme type

#

dimmed, dark or something

slate swan
#

Lemme check

#

Iirc, dark

shadow wraith
#

wtf is lirc

slate swan
slate swan
shadow wraith
slate swan
#

uh i'm confused on something , so i've got a blacklist command that blacklists words that cannot be snipped nor sent , like they get deleted but i've got it running like this

    @tasks.loop(seconds=5)
    async def my_loop(self):
        x = await self.bot.db.fetch("SELECT blacklisted FROM blacklist")
        lst = ' '.join(words["blacklisted"] for words in x)
        lst = list(lst.split(' '))
        self.blacklisted_stuff = lst
    
@commands.command(aliases=['s'])
    async def snipe(self,ctx):
        if self.message is None: return await ctx.send('there are no deleted messages')
        embed = discord.Embed()
        embed = discord.Embed(title="   ",description=f"{self.message}")
        embed.set_author(name=self.author.name,icon_url=self.author.avatar_url)
        embed.set_thumbnail(url=self.author.avatar_url)
        embed.set_footer(text=f'requested by {ctx.author.name}',icon_url=ctx.author.avatar_url)
        await ctx.send(embed=embed)
```and this
```py
    @commands.Cog.listener()
    async def on_message(self,message) -> None :
        if message.author.bot: return
        msg = message.content.lower()
        new_string = "".join(c for c in msg if c.isalpha() or c == " ")
        lastest_string = new_string.split()
        x,y = set(lastest_string) ,set(self.blacklisted_stuff)
        if x & y:
            await message.delete()
            await message.author.send(embed=discord.Embed(title=f"you've sent a blacklisted word in {message.guild.name}",description=f"Blacklisted word : {x & y}"))```
but i'm making my bot public but theres one thing i'm confused about , how would i make my task update for each guild . and i thought someone here must know another way thats better , so i was asking if there is a way to do so ?
shadow wraith
#

sniping is against tos

gentle rose
#

How to trigger custom guild roles?

shadow wraith
#

you cant get the content of a deleted message

#

they are never meant to be accessed.

slate swan
shadow wraith
#

nah people just said

slate swan
#

okay then , when you get a trusted source , tell me its against tos

slate swan
#

dude said you cant get content of deleted messages when there are logs

slate swan
#

It's not against tos... but... it's just bad practice and people don't like it often

#

bad practice ?

#

lmao how is making a command bad practice smh

#

please i'm not here to argue

final iron
slate swan
#

Yeah you don't want your deleted message gets sniped by someone random in chat

slate swan
slate swan
#

and either ways it would be on logs so why bother

#

just clear bs tbh

final iron
slate swan
#

umm ik..

#

okay back to my question

slate swan
#

Design your database to store blacklisted words for every guild instead of just one, and run the tasks accordingly

maiden fable
#

Ffs I hate JS more than Python now

#

Wait wrong channel (or server maybe? who knows)

slate swan
maiden fable
gentle rose
# slate swan can you elaborate ?

I have this role(check screenshot).
And i want to trigger all users that have this role, with if statement.
for example:

if '<@&693935970030059521>' in user.roles:
    return
slate swan
slate swan
manic wing
maiden fable
gentle rose
manic wing
unkempt canyonBOT
slate swan
manic wing
peak loom
#

@manic wing Help my bot stopped working.

slate swan
#

Read your error

peak loom
#

I am.

slate swan
#

It's clearly mentioned there

final iron
manic wing
slate swan
#

what are you confused at?

manic wing
#

meaning the replit ip gets ratelimited

#

another reason why replit isnt a great host

peak loom
manic wing
#

well yeah if you keep your computer online 24/7

slate swan
#

vsc is an editor-

peak loom
tawdry perch
#

I would say a cheap vps

slate swan
#

buy a cheap one acc to ur requirements

tawdry perch
#

Even tho I'm using a free host atm

slate swan
#

Me kinda free too-

tawdry perch
#

I have 500mb free storage and 65%of cpu which is more than enough for my bot

rare saddle
#

Why if you click on the button in the menu from different servers, then channels with reports will be created only on one server, and not where you clicked the button

manic wing
#

nice

peak loom
#

@final iron

peak loom
quaint epoch
manic wing
#

i dont know

#

i just use my pi

#

never used a vps

slate swan
proven osprey
#

guys, please tell me what is the problem? i did everything right, but when i enter the command it doesn't work

manic wing
# quaint epoch um idk

if you dont know, dont say. this server wouldnt be very helpful if everyone came and said 'idk'

quaint epoch
#

my code

#

and i was also playing a game so i would've died

rare saddle
#

What to do if a bot takes a category from the first document for all reports

proven osprey
slate swan
#

Did you restart your bot after adding command?

manic wing
#

is the bot online?

quaint epoch
proven osprey
#

oh

#

it worked thank you

slate swan
#

....

proven osprey
#

thanks for help

upbeat otter
manic wing
#

yes.

#

if the code doesnt work, adding a check wont help either.

manic wing
#

in fact, it makes it less likely to work.

quaint epoch
#

i just write code, don't test it, add a check then the next day i panic when it returns an error or doesn't work

upbeat otter
upbeat otter
maiden fable
#

I swear handling 3 DMs at a single time each doing a different thing is a real pain

quaint epoch
#

and yes it sucks

gentle rose
#

How to mention guild role by ID in message? ID of my role: 693935970030059521

gentle rose
#

ah, ok

#

if i simpy code it with:

await channel.send('ping role - <@&id>')
#

it'll ping?

slate swan
#

Yes

gentle rose
#

thanks

quaint epoch
#

is it possible to compress a 250 mb vid to 8mb?

unkempt canyonBOT
quaint epoch
stiff nexus
#

what will str(error.param).split(':')[0] do?

maiden fable
#

what is error

velvet tinsel
#

making an IDE is hard
I'm still on the menu

barren creek
#

does anyone know what the function is that turns mentions into plaintext, but not the id, the actual name and discriminator

slate swan
#

any help

sage otter
queen jewel
#

i got a question

``` works, i mean it counts from 1 to 10000

but when i try 
```for i in range(9999999999999999, 0):

its not working?

maiden fable
#

yea

#

!d range

unkempt canyonBOT
#

class range(stop)``````py

class range(start, stop[, step])```
The arguments to the range constructor must be integers (either built-in [`int`](https://docs.python.org/3/library/functions.html#int "int") or any object that implements the `__index__` special method). If the *step* argument is omitted, it defaults to `1`. If the *start* argument is omitted, it defaults to `0`. If *step* is zero, [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "ValueError") is raised.

For a positive *step*, the contents of a range `r` are determined by the formula `r[i] = start + step*i` where `i >= 0` and `r[i] < stop`.

For a negative *step*, the contents of the range are still determined by the formula `r[i] = start + step*i`, but the constraints are `i >= 0` and `r[i] > stop`.
maiden fable
#

first arg is the start then stop

barren creek
#

i swear there is a function that just process the text and does it

maiden fable
#

and step is by default 1

barren creek
#

i just cant find what its called

queen jewel
#

yea

maiden fable
unkempt canyonBOT
#
Not in a million years.

No documentation found for the requested symbol.

maiden fable
#

!d discord.ext.commands.Context.clean_prefix

unkempt canyonBOT
maiden fable
#

This?

queen jewel
#

i still dont get it tho

#

what do i gotta do so it works?

maiden fable
#

9999999, 0, -1

queen jewel
#

ohhh

maiden fable
#

add the -1 also

queen jewel
#
      for i in range(99999999999, 5, -1):
        await message.channel.send(i)```
#

so it should be like that?

maiden fable
#

damn u do be ratelimited

queen jewel
#

yeah i know i am gonna be

maiden fable
#

sending 99999995 messages

#

then why send them

queen jewel
#

yeah its a countdown

#

idk im just bored

maiden fable
#

bruh

barren creek
#

thanks

queen jewel
#

its not working when i open it

wild oak
#

I'm not on right now but it is possible to make a command that uses Instagram to get and show the latest post on someones account

unkempt canyonBOT
maiden fable
#

Use this ig

wild oak
#

😩😩😩

maiden fable
#

Or use aiohttp and send raw requests who knows

velvet tinsel
#

Hai hunter

#

And tylerr

wild oak
#

there's no docs 😩

barren creek
maiden fable
#

cool

slate swan
#

Open the homepage section

wild oak
#

Oh 😩

cloud dawn
#

Or use reddit instead :D

slate swan
#

They need someone's insta acc data in particular ig

#

And reddit has some nice data in it, made me left reddit since I saw it shipit

unkempt canyonBOT
#

Download pictures (or videos) along with their captions and other metadata from Instagram.

shadow wraith
slate swan
velvet tinsel
#

Greetings all

gentle rose
#

How can i give permission to write in channel to a user in on_reaction_add event?

my code:

@bot.event
async def on_reaction_add(reaction, user):
    channel = bot.get_channel(916255565896892426)
    await channel.set_permissions(user, send_messages=True)
upbeat otter
velvet tinsel
#

“Love”?

#

“Dear”?

#

😳

upbeat otter
gentle rose
upbeat otter
wild oak
#

How would i be able to have a command thats like -instagram (no im just gonna do it without the thing u showed me cuz i give up) but like -instagram set "link" then have it send a message to a channel saying Hey go like this post or something like that

#

i just need help doing the link

#

and the specific channel to send

gentle rose
upbeat otter
wild oak
#

Please help lmao

wanton veldt
#

when I kick someone to print in logs that I kicked ("member" has been kicked). how can i make that ```py

@client.command()
@commands.has_permissions(kick_members = True)
async def kick(ctx, member : discord.Member, *, reason = None):
await member.kick(reason = reason)
await ctx.channel.send(f'{member.mention} has been kicked by {ctx.message.author.mention} for reason of: {reason}!')
print(f"")

wild oak
#

this has nothing do to with helping you but why do you have it do print(f"")

wanton veldt
#

ignor the last line

wild oak
#

ok

upbeat otter
wanton veldt
#

i want something like that

#

but i dont understand how to do it

upbeat otter
#

!d discord.ext.commands.Bot.get_channel

craggy cloak
#
@client.command()
async def online(ctx):
  online = ("https://caprihotel.nl/api/online")
  await ctx.reply(f":yes: there are ... {online} online!")

I am testing something with a certain Link I would like the bot to send the amount of the number of users online but it just sends the link how do I fix this?

unkempt canyonBOT
wanton veldt
upbeat otter
wild oak
#

and also are you using that command in a cog

#

OH

#

nvmd lmao

upbeat otter
wanton veldt
#

print

upbeat otter
slate swan
upbeat otter
gentle rose
#

What im doing wrong here? I want to give role when user reacted

@bot.event
async def on_reaction_add(reaction, user):
    guild_role = discord.utils.get(reaction.message.guild.roles, name="wannaplay")
    await user.add_roles(guild_role)
gentle rose
slate swan
upbeat otter
gentle rose
slate swan
upbeat otter
#

Smh help then

#

@gentle rose try using exceptions

slate swan
finite apex
slate swan
#

it just did for me ```py
@bot.event
async def on_reaction_add(reaction:discord.Reaction, user:discord.User):
guild_role = discord.utils.get(reaction.guild.roles, name="wannaplay")
try:
await user.add_roles(guild_role)
except Exception as e:
print(e)

#

just make sure you are actually getting a role

gentle rose
#

i tried with debug - print(reaction) and got nothing in console lol

#

hmm, wtf

dusk dust
#

does anyone have any tutorials for me talking about how to make a web scrap using discord.py? send on dm, pls

gentle rose
#

ah, find solution. event can't get old messages

gentle rose
dusk dust
final iron
#

That's not how you make a web scraper

slate swan
final iron
#

Dpy is a library intended for creating discord bots

slate swan
#

^^

dusk dust
craggy cloak
#
@client.command()
async def tester(ctx):

        url = f'https://caprihotel.nl/api/{online}'


        async with ctx.typing():
            async with aiohttp.request("GET", url, headers={}) as a:



                embed = discord.Embed(
                    title=f"Users online {online}",colour=ctx.author.colour,timestamp=datetime.utcnow(),)
                await ctx.send(embed=embed)

Idk if this is correct but it is not working?

slate swan
#

do you asking if it's not working

slate swan
craggy cloak
slate swan
#

and how are you supposed to know that?

#

you have to define it

slate swan
craggy cloak
slate swan
craggy cloak
slate swan
dusk dust
slate swan
#

thats what i get, where are you in the world

slate swan
craggy cloak
slate swan
#

where are you in the world, netherlands?

craggy cloak
#

yes

slate swan
#

give me a moment

#

ah okay let me do this for you very quickly

craggy cloak
#

how can i define that {online} ?

slate swan
#

im doing it now give me a minute

upbeat otter
dusk dust
#

Jenkins, do you have DiscordComponents library link?

#

thanks

slate swan
craggy cloak
upbeat otter
slate swan
#

well the website is actually stupid and doesnt allow requests, it asks "to turn on javascript"

#

and cloudflare stops you at an instant

#

<p data-translate="turn_on_cookies" style="color:#bd2426;">Please enable Cookies and reload the page.</p>

craggy cloak
#

There's only one thing left to do, right? I just have to define {online} right? but how pithink

slate swan
#

well, you dont actually need to define online

gentle rose
#

How to send programming styled text in discord.py?
Like this:

lorem ipsum
gentle rose
#

ah, thanks! how about bold text?

slate swan
slate swan
gentle rose
#

thanks!

craggy cloak
slate swan
#

so i dont know where i can go from here so yeah

craggy cloak
#

o ok no problem

rapid pebble
gentle rose
#

thanks!

#

How to delete role of target user?

dusk dust
#

whats wrong? i copied the check= from docs just to see how it works but apparently it doesn't work

    await ctx.send("testing", components=[Button(label="Button number one", custom_id="btn")])
    interaction = await client.wait_for("button_click", check=lambda inter: inter.custom_id == "btn")
    await ctx.send('nice interaction')
slate swan
#

is discord certified moderator in public flags ?

velvet tinsel
#

hello all

velvet tinsel
dusk dust
velvet tinsel
#

I think he was asking a question

#

or maybe not

slate swan
#

The badge

velvet tinsel
#

ok

#

meh

#

*flags

dusk dust
velvet tinsel
dusk dust
#

ah

velvet tinsel
#

or maybe not idk sounds like a question

slate swan
velvet tinsel
#

maybe it's an error but I dont see public flags to do with your code

velvet tinsel
slate swan
#

Correct

velvet tinsel
#

wait thats hypesquad

#

@slate swan maybe that's what you're looking for

craggy cloak
slate swan
craggy cloak
#

no

final iron
quaint epoch
#

How do I get an members message history?

#

because i always get this returned

#

here is the code

steep drift
#

Hey do any of you guys know how to make a streaming bot

#

!play YoutubeLink

#

then it will stream the videi

#

can you do that.

sick birch
#

Bots can't steam video, so no

quaint epoch
velvet tinsel
#

Is it ok if I put a useless piece of code in my github ;-;

velvet tinsel
untold token
#

this is not asynchronous

#

It will block your code

velvet tinsel
#

like

"""
def foo():
  print("foo")
"""
untold token
#

So

sacred nest
#

!rank

unkempt canyonBOT
#

Iterating over range(len(...)) is a common approach to accessing each item in an ordered collection.

for i in range(len(my_list)):
    do_something(my_list[i])

The pythonic syntax is much simpler, and is guaranteed to produce elements in the same order:

for item in my_list:
    do_something(item)

Python has other solutions for cases when the index itself might be needed. To get the element at the same index from two or more lists, use zip. To get both the index and the element at that index, use enumerate.

untold token
#
channel = await ctx.guild.get_channel(ID)
history = await channel.history(limit=100).flatten()  # flattens, returns a list of messages

#

@quaint epoch

untold token
#

!d discord.TextChannel.history

unkempt canyonBOT
#

async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the destination’s message history.

You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.

Examples

Usage...
untold token
#

You can pass a check in that method where it checks it only returns the members messages, you want for

velvet tinsel
#

ah finally
another helper
I don't have to teach beginners what SyntaxErrors are anymore

#

or IndexError

#

or ValueError

#

or TypeError

#

or the NoneType thing

#

whatever that is

#

or any other error tbh

#

🙂 thank you

#

still typing? ok

untold token
#
messages = []
channel = ctx.guild.get_channel(ID)
member = ctx.guild.get_member(ID)
async for message in channel.history(limit=100): 
    if message.author == member:
   await messages.append(message)
untold token
velvet tinsel
#

it's wrong

#
messages = []
channel = ctx.guild.get_channel(ID)
member = ctx.guild.get_member(ID)
async for message in channel.history(limit=100): 
    if message.author == member:
      await messages.append(message)

you forgot a tab

#

T_T

untold token
#

Basically what's happening here is I am looping through each message in the channels history and checking the if there is a message in the channel with the member that want to check for, if there is, it will append the messages list

velvet tinsel
#

that explains

untold token
#

So indentation will be wrong

#

And they can fix indentation themselves

velvet tinsel
#

also

untold token
#

So don't make very large queries

#

You can get ratelimited

velvet tinsel
#

you can do ctx.author?

#

or maybe not

untold token
#

They want the author of the message

velvet tinsel
#

alright

#

can't you also put the author in a dict?

#

and add values to the key whenever the same author sends it?

untold token
#

It wouldn't make it faster or more efficient

#

And it's more to code it

#

Lists are good enough

velvet tinsel
#

I wouldn't recommend it either

#

I tried that once

#

total mistake

#

broken af
maybe it's because of the reddit API or what idk

#

!pypi reddit

unkempt canyonBOT
velvet tinsel
#

!pypi PRAW

unkempt canyonBOT
#

PRAW, an acronym for `Python Reddit API Wrapper`, is a python package that allows for simple access to reddit's API.

velvet tinsel
#

!pypi asyncpraw

unkempt canyonBOT
#

Async PRAW, an abbreviation for `Asynchronous Python Reddit API Wrapper`, is a python package that allows for simple access to reddit's API.

velvet tinsel
#

hurrr

verbal cairn
#

how can u send a message to a specific channel

worthy wagon
#

Anyone know why this isn't working

dusk dust
#

is there any way i can make the bot click on some item within a website?

worthy wagon
#

Can you not have 2 on_raw_reaction_add events in 2 different files?

quaint epoch
#

how do i get the current guild id?

unkempt canyonBOT
#

discord.on_raw_reaction_remove(payload)```
Called when a message has a reaction removed. Unlike [`on_reaction_remove()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_reaction_remove "discord.on_reaction_remove"), this is called regardless of the state of the internal message cache.

This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
worthy wagon
quaint epoch
#

fetch/get, anything works

#

i don't want to manually enter the current guild id, i want tot bot to get it

#

how to do that?

quaint epoch
#

thanks!

#

hey, anyone know how i can disable embeds on messages that my bot sends

#

???

#

Because when my bot sends a link

#

and embed appears with it

#

how do i disable that?

worthy wagon
#

disable embeds in the channel settings?

quaint epoch
worthy wagon
#

Then, I don't believe so

worthy wagon
# unkempt canyon

If anyone can get back to me on this, I'd appreciate it, it's not removing the roles when the reaction is removed, the code is listed below:

    @commands.Cog.listener()
    async def on_raw_reaction_remove(self, payload):
        latency = round(self.bot.latency * 1000)
        messageID = 916814759360335872

        if messageID == payload.message_id:
            member = payload.member
            guild = member.guild
            
            emoji = payload.emoji.name
            if emoji == '🥶':
                member = payload.member
                mrole1 = discord.utils.get(guild.roles, id=916548833641627679)
                await member.remove_roles(mrole1)

            emoji = payload.emoji.name
            if emoji == '🥱':
                member = payload.member
                mrole2 = discord.utils.get(guild.roles, id=916548881943240724)
                await member.remove_roles(mrole2)
quaint epoch
#

well then does anyone know how to set messages flags in await ctx.send('message')?

verbal cairn
#

Anyone know why my slash commands don’t show up when my bot joins a new server

verbal cairn
kindred epoch
#

show your commands.Bot line

verbal cairn
#

Wdym

#

U mean @bot.slash_command()

#

?

kindred epoch
#

show me the line where you defined bot

verbal cairn
#

It doesn’t have test guilds

#

It has prefix=“!” And case insensitive=True

#

I’m not at pc rn

kindred epoch
verbal cairn
#

And the bot works in 4/8 servers

kindred epoch
verbal cairn
kindred epoch
#

idk ask it in their support server

#

someone in that server already answered you

verbal cairn
#

How do u add applications.command to the scope

kindred epoch
#

same way you add the bot scope

vale glen
#

i kinda forgot how though lol

kindred epoch
#

get_channel

slate swan
#

how can i check if a catigory exists

slate swan
# kindred epoch get_channel
        B = discord.utils.get(ctx.guild.channels, name="Terminations")
        await ctx.channel.edit(category=B)

    if B is None:```
#

i need to check if the category by the name 'terminations' exists or not

vale glen
#
var = client.get_channel(int(channelid))
slate swan
#

without channel id, just name

vale glen
#

wasnt replying to u

slate swan
#

ah

verbal cairn
verbal cairn
#

Maybe? Idk

spark kite
#

I have a simple question how would I get my bot to put a blank space after a message without sending two messages

#

Like letting the bot press the enter key inside of one message

verbal cairn
#

Add a “\n”

#

At the end of whatever ur string it message is

slate swan
spark kite
slate swan
#

but ive never heard of get_category so

spark kite
#

Thank you

verbal cairn
slate swan
spark kite
# verbal cairn Add a “\n”

wait when I do that it prints the /n.
my codes is

await member.send( str(message.author) + " told me to tell you that:"  + "/n"  + " ".join(sentence[2:len(sentence)]))
verbal cairn
#

\n

#

not /n

spark kite
#

ohhh

#

thank you

verbal cairn
#

np

spark kite
#

Does anyone know how I can check if a message has an attachment?

quaint epoch
#

does anyone know how to send files?

#

is it py await ctx.send(file='file.txt')

#

or what?

verbal cairn
#

dont think so

#

cuz u cant just send a file that isnt opened or whatever I dont think

#

otherwise it will just return the file name

quaint epoch
verbal cairn
#

file.read() id think

quaint epoch
verbal cairn
#

uh probably? I dont think theres a files **kwargs

#

in ctx.send at least

quaint epoch
#

I edited it, would it work then?

verbal cairn
#

try it!

#

im not like professional python guy ive only been doing this for a few weeks

rare saddle
#

How to make the buttons work until the bot is restarted?
Library - dislash
in cogs

verbal cairn
#

idk if it has it, but commands.Bot(command_prefix="!", reload=False)

#

maybe? not sure

#

anyone know how to display only the names of the guilds when I use like bot.guilds

rapid pebble
slate swan
#

They actually don't

sick birch
#

async defines a coroutine, rather than a normal python function
await waits for a couroutine to finish, and get the result

#

Both are very important components of asynchronous programming

#

You'll find it in other languages too, for example, JavaScript's promises

#

An asynchronous function that doesn't block

#

It's sort of a fire the function, do something else, come back and get the result

polar ice
#

hello, ive made a button for a ticket system. everything seems to be working as it should but is there another way i can make it so the button is always responsive not just after when you type the command?

        response = await client.wait_for("button_click", check=lambda i: i.component.id in button_ids and i.author.id == ctx.author.id and i.message.id == interaction.id, timeout=None)  # You can change the timeout

        if response.custom_id == 'open_ticket':
            await response.respond(type=6)
            print(f"{ctx.author.name} has just opened a ticket")
            ticket_channel = client.get_channel(ctx)
            await ticket_system(ctx.author.id, ticket_channel, 1)```

This is what i have at the bottom of the command. but once i restart the bot i then need to re-do the command instead of it always being active
sick birch
#

Rather than in normal python, it fires the function, waits on it to finish, and then does something else, sort of like a queue

sick birch
#

A very very simplified version, yes

#

No problem, it took me a while to understand the whole thing haha

slate swan
#

So I defined mytest and all words are in a text file.

I put them in a tuple like mytest = tuple(mytest)

I want to check to see if a member's nickname has the word(s) in the file.

So I did if after.display_name in (mytest):

So now when I put it like just the word in my name it works. But when I add

hi before or after the word in the file it doesn't do stuff that I wanted it to do below which is rename

#

Please ping on reply

#

i got something like that when i run my bot i just dowload mudle i dont even add the modle to the code of my bot or somethin

#

cuz i dont know

sick birch
#

What's a mudle/modle?

#

Do you mean a module?

slate swan
#

yeah

sick birch
#

Basically it says you can't have nextcord and discord.py at the same time

#

you'll have to uninstall one of them

#

either do
pip3 uninstall discord.py to uninstall discord.py
or do
pip3 uninstall nextcord to uninstall nextcord

slate swan
#

oh

heavy folio
dim rose
#

hello

#

I wonder if it is a bug?

kindred epoch
lyric ibex
#

what is the name of the owner of this discord mark it please

heavy folio
#

why

heavy folio
boreal ravine
sick birch
boreal ravine
#

¯_(ツ)_/¯

ocean leaf
#

without the fourth line my code works but with the third line, it dosen't. Not even error.

quaint epoch
#

how do i get a list of members in my guild?

ocean leaf
quaint epoch
ocean leaf
#

or if u wanna use the current guild, then ctx.guild.members

quaint epoch
#

uh, did what you said but it only returned info on me?

ocean leaf
quaint epoch
ocean leaf
#

worked for me

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.members = True

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

quaint epoch
boreal ravine
jade tartan
#

How do i add roles to members automatically by my bot?

boreal ravine
quaint epoch
boreal ravine
unkempt canyonBOT
#

await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
quaint epoch
#

idk why i added the 2nd lol

boreal ravine
quaint epoch
#

[<Member id=909639627374202890 name='HRLO77 test bot' discriminator='9637' bot=True nick=None guild=<Guild id=885170029824450580 name='R8A' shard_id=None chunked=False member_count=15>>]

#

that is the full output

#

so why is it not giving all of the members?

#

shit it only returned ITSELF, not me

boreal ravine
boreal ravine
boreal ravine
quaint epoch
boreal ravine
#

and client

quaint epoch
boreal ravine
#

o

quaint epoch
#

it says i should rename the element

#

nothing major

#

pycharm is like that

jade tartan
#

to members

#

or just the await

boreal ravine
jade tartan
#

ok

rain olive
# quaint epoch

why is client a var that holds your bot instance and ur bot var is discord.Client() ?!?!?@,@@

quaint epoch
rain olive
#

consider renaming ur client to bot as well lol

boreal ravine
steep drift
#

Google Definition: Python pickle module is used for serializing and de-serializing a Python object structure. Any object in Python can be pickled so that it can be saved on disk. What pickle does is that it “serializes” the object first before writing it to file. Pickling is a way to convert a python object (list, dict, etc.)

#

Basically It's good for orginization among other stuff similar to that

steep drift
#

yes sorry

#

grammar mistake

#

It will make you code much neater.

#

But I'm sure it has other uses as well.

#

yeah, lol

#

odd name I guess

#

Your welcome my man!

#

:D

jade tartan
#
async def on_member_join(member):
        guild = client.get_guild(730651046459998218)
        channel = await (await client.fetch_channel(885464532959526913)).send(f'Welcome to server **{member.mention}**.')
        role = guild.get_role(832120561848156180)
        role = guild.get_role(862632463615262730)
        role = guild.get_role(849093239285743647)
        role = guild.get_role(853980922243711007)
        role = guild.get_role(851020933053546537)
        role = guild.get_role(856124625482547250)
        role = guild.get_role(862630645658681364)
        role = guild.get_role(862629105019519006)
        role = guild.get_role(862662802161795072)
        role = guild.get_role(862662586024853504)
        role = guild.get_role(851021143040327680)
        role = guild.get_role(856123770020692040)
        role = guild.get_role(856123532747472916)
        role = guild.get_role(862667562634051614)
        role = guild.get_role(852477636961108008)
        role = guild.get_role(862669289353904158)
        role = guild.get_role(862670413632634930)
        role = guild.get_role(862670842735624233)
        await member.add_roles(role)
        print(f"{member.name} has joined the server")```
steep drift
jade tartan
#

Right?

ocean leaf
sick birch
#

Useful when you want to store objects inside a database or json as a primitive

ocean leaf
#

i just replaced _ with " "

sick birch
#

For example if you wanted to store your bot instance in a json file, you’d pickle it

ocean leaf
jade tartan
#

Hello

ocean leaf
steep drift
jade tartan
ocean leaf
ocean leaf
#

ano ot channel

steep drift
#

maybe get rid of the ('_')

#

but what is this program used for?

#

that will help me better understand your problem

#

does it have to do with Web Hooks?

steep drift
#

all the variables are named role is that intentional?

ocean leaf
steep drift
#

Also if I can't help go to Stackoverflow

ocean leaf
steep drift
#

oh I think I know your problem

#

the concatenation goes to an empty string

#

maybe instead of that empty string put some form of information

quaint epoch
#

hey guys i found the mistake in my code, i did Intents=intents instead of intents=intents :/

steep drift
#

because there is no point of concatinating 2 strings

#

might have spelled that wrong

#

The only other thing I can think of is maybe use a Table (the square brackets) instead of the ones you are currently using

#

Sorry if I wasn't much help.

quaint epoch
#

how do i check if a member is an admin?

slate swan
jade tartan
quaint epoch
#

i know how to do that

slate swan
jade tartan
#

i believe that this is the correct one. role = get(member.guild.roles, name='•.¸¸.•:Colours:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•')

steep drift
#

maybe

#

lol