#discord-bots

1 messages · Page 952 of 1

cold sonnet
#

bad bot

slate swan
#

@final iron let me show you something funny

final iron
#

🗿

slate swan
#

!e

print                                 ("no errors!")
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

no errors!
maiden fable
#

Can u both take this to an ot?

modern fiber
#

what the fuck is that bro just edit my code please dude

daring olive
#

try using inspect.Signature

maiden fable
slate swan
daring olive
final iron
#

Wat

slate swan
daring olive
final iron
#

Oh yeah

slate swan
#

he said it was something dumb i made when its not lmfao

maiden fable
#

The person dk what they asked for but the helper does 😔

slate swan
final iron
#

🗿

daring olive
#

i knew it was a thing but didn't know you could actually get it from inspect

slate swan
#

no

daring olive
slim ibex
#

i created the 🗿 trend here

final iron
slate swan
#

but mina🗿

slim ibex
maiden fable
slate swan
#

🗿

slim ibex
#

i am the 🗿 master

daring olive
#

if it can be construed as rude or dismissive even in the sliiiiiiiiiightest way i'd rather you guys not

#

i'm interpreting it as "bruh"

slate swan
slate swan
daring olive
#

i mean am i wrong?

maiden fable
slate swan
daring olive
#

it feels like a mixture of "bruh" and "duh"

slim ibex
#

I started using it as something sarcastic/to show something is funny or interesting i guess

slim ibex
#

i don't think we have ever used it in a demeaning way though

slate swan
#

i dont use it in a regular basis so i wouldnt know

slate swan
daring olive
#

i get that a lot of you are friends and are probably fine with it... but even with my close friends i am careful to use language/emoji that is not likely to be misunderstood by third parties as me being rude

maiden fable
#

can we take this to an OT chat?

slim ibex
cold sonnet
slim ibex
slate swan
slim ibex
#

^

slate swan
#

we do it like a bruh moment and then we continue to help the person mostly thats what i do sometimes which is rarely that i use that emoji

daring olive
#

yeah i understand. just pls be mindful of it (speaking to everyone here)

slate swan
daring olive
#

you mean the regulars? yeah that would be great if you guys set a stellar example :)

boreal ravine
#

should I make a replica of discord inside a bot heheboi

slate swan
gilded zephyr
#
# Base BTC Command
@commands.group(name = "btc", invoke_without_command = True) # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
async def btc(self, ctx, *args):
    #await ctx.reply("Unknown command: Use `-btc` for help with BTC commands.", mention_author = False)
    if ctx.invoked_subcommand is None:
        await ctx.reply(embed = helpEmbed, mention_author = False)
    
# Address Command
@btc.command(name = "addr", aliases = ["address", "a"])
async def btc_addr(self, ctx, addrVal):
    await ctx.reply("Test Passed")

Why doesn't my subcommand work unless have invoke_without_command = True (where are the arrows are)

slate swan
cold sonnet
#

oh star

slate swan
daring olive
cold sonnet
#

🙂

slate swan
slim ibex
#

ah ok

daring olive
slate swan
#

😭

cold sonnet
#

😳

boreal ravine
toxic bluff
#

Hey, how can the bot do an action based what a user chose in an disnake.ui.Select (select Menu in discord)? I already created the select menu and attached it to a message. I just need my Bot to do something if a user clicks on an option.

slate swan
slate swan
#

depending on your lib theyre would be examples on the repo

boreal ravine
cold sonnet
slate swan
lament mesa
cold sonnet
#

perhaps I can find an example

toxic bluff
#

thanks

cold sonnet
#
    async def callback(self, interaction):
        await interaction.response.defer()
        if not interaction.author == self.ctx.author:
            return await self.ctx.send(f"**{interaction.author}, nem te.**")
        value = self.values[0]
        if value == "Január" or value == "Március" or value == "Május" or value == "Július" or value == "Augusztus" or value == "Október" or value == "December":
            days = 31
        elif value == "Április" or value == "Június" or value == "Szeptember" or value == "November":
            days = 30
        else:
            days = 28
        newOptions = [
            SelectOption(
                label=str(day)
            ) for day in range(days+1)
        ]
        await interaction.message.edit(
            content="**A szülinapod...**", 
            view=View(
                Day(
                    value, 
                    newOptions[1:16], 
                    self.ctx
                ), 
                Day(
                    value, 
                    newOptions[-(days-15):], 
                    self.ctx)
            )
        )
        await self.ctx.send(f"**A kiválasztott hónap: {value}**")
#

horrible example

#

if value in (stuff):
would've made it so much easier

toxic bluff
#

okay I will try it thank you

gilded zephyr
#
# Base BTC Command
@commands.group(name = "btc", invoke_without_command = True) # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
async def btc(self, ctx, *args):
    #await ctx.reply("Unknown command: Use `-btc` for help with BTC commands.", mention_author = False)
    if ctx.invoked_subcommand is None:
        await ctx.reply(embed = helpEmbed, mention_author = False)
    
# Address Command
@btc.command(name = "addr", aliases = ["address", "a"])
async def btc_addr(self, ctx, addrVal):
    await ctx.reply("Test Passed")

Why doesn't my subcommand work unless have invoke_without_command = True (where are the arrows are)

maiden fable
#

nvm

cold sonnet
#

yert

slate swan
maiden fable
#

czzz that is when u defer?

slate swan
#

it seems unnecessary to me

cold sonnet
#

cuz it lasts more than 3 seconds to answer

slate swan
maiden fable
#

its helpful, especially when yr ping is too much. also prevents useless errors

cold sonnet
#

it didn't work elseway

#

also, my raspberry is slow as hell

slate swan
maiden fable
#

Huh?

cold sonnet
#

makes the response work too

slate swan
maiden fable
#

who said that

gilded zephyr
spice basalt
#

why isn't this giving me an output?

modern fiber
#

Can someone help, how do I "translate" this line to disnake library?

#
@client.slash_command(name = 'timeout', description = "mutes/timeouts a member")
@commands.has_permissions(moderate_members = True)
async def timeout(ctx, member: Option(discord.Member, required = True), reason: Option(str, required = False), days: Option(int, max_value = 27, default = 0, required = False), hours: Option(int, default = 0, required = False), minutes: Option(int, default = 0, required = False), seconds: Option(int, default = 0, required = False)): #setting each value with a default value of 0 reduces a lot of the code
    if member.id == ctx.author.id:
        await ctx.respond("You can't timeout yourself!")
        return
#

Anybody? - The one with options.

cold sonnet
#

why do you need all these Option stuff

#

actually, I don't know much about these since I haven't tried them, so I won't say anything stupid

final iron
spice basalt
final iron
#

member is None because you set it to default to that value

#

Also you're using avatar.url and avatar_url

#

Pick the one that corresponds to your dpy version

#

avatar.url would be 2.0

final iron
#

Have you considered using a formatter like black to make it more readable?

#

IMO it would help a lot

spice basalt
cold sonnet
#

you did not input anything for member

#

therefore, it's None

#

you could also check if it's None at the start

spice basalt
cold sonnet
#

like:

    if member is None:
        return await ctx.send("Who?")
spice basalt
#

i mentioned myself

#

🗿

cold sonnet
#

oh

#

remove self from the args

#

I did overlook that...

#

you only need self in cogs

#

and other classes

#

which you don't have

spice basalt
#

now it gives me another error

cold sonnet
#

you're on dpy 1.7?

spice basalt
#

i'm not even sure anymore at this point

cold sonnet
#

pretty sure you are...

spice basalt
#

then yes

cold sonnet
#

try replacing avatar.url with avatar_url

#

iirc member.avatar is a string in 1.7

spice basalt
#

👍

cold sonnet
spice basalt
#

it works now

#

thank you

cold sonnet
#

that's a weird gif

#

you're welcome I guess

slate swan
spice basalt
#

can i make it so that i don't have to mention myself tho?

cold sonnet
#

oh yes, easy one liner

#

member = member or ctx.author

#

so if member is None originally, it will choose ctx.author, which is you

spice basalt
#

ah

cold sonnet
#

or whoever invokes the command

spice basalt
#

but it'll still work if i mention someone else tho, right?

cold sonnet
#

then you don't have to check if it's None

cold sonnet
#

in that case, it sets itself to itself

gilded zephyr
#

is there a way to get the name of a missing required argument from the exception?

spice basalt
#

it just shows the person using the commend and not the person mentioned

cold sonnet
#

you used ctx.author instead of member somewhere

spice basalt
#

i want it to show something like
you#0000 if you are the one using it on yourself and
mentioned user#0000 if you are mentioning someone else

cold sonnet
#

well replace it

#

!d discord.ext.commands.MissingRequiredArgument

spice basalt
unkempt canyonBOT
#

exception discord.ext.commands.MissingRequiredArgument(param)```
Exception raised when parsing a command and a parameter that is required is not encountered.

This inherits from [`UserInputError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.UserInputError "discord.ext.commands.UserInputError")
spice basalt
cold sonnet
spice basalt
#

yes

cold sonnet
#

how come

cold sonnet
#

!d discord.ext.commands.MissingRequiredArgument.param

unkempt canyonBOT
spice basalt
cold sonnet
#

not ctx.member

spice basalt
cold sonnet
#

just member

#

and I think you can do

spice basalt
#

ah i see

cold sonnet
#

f"{member}"

#

that should give the same thing

spice basalt
#

i forgor ctx isn't needed as it's member

spice basalt
tacit token
#

Guys, how can i off the delete? if i ban someone the bot delete the message history

@commands.has_permissions(ban_members=True)
@client.command(name="ban")
async def ban(ctx, member : discord.User, *,reason = "No reason was provided"):
    banhammer=":ban_hammer:"
    reason = "".join(reason)
    embed=discord.Embed(title=f"{member} Banned from {ctx.guild.name} {banhammer}", description=f"\nModerator:{ctx.author.mention}\nreason: {reason}\nTime: ∞",color=0x34568B,timestamp=ctx.message.created_at)
    embed.set_thumbnail(url=member.avatar_url)
    embed.set_footer(icon_url=member.avatar_url, text=f"{member.name} | {member.id}")
    await ctx.send(embed=embed)
    await ctx.guild.ban(member,reason=reason)
hasty lake
hasty lake
#

👌

spice basalt
#

it's supposed to say
"You are ..." if you don't mention anyone and
"<mentioned_user> is ..." if you mention someone (also i want it to only say the name without the discriminator)

cold sonnet
#

member is never None

#

you set it to ctx.author if it's None

#

remove member = member or ctx.author here

#

or you could

#

member = member or "you"

#

and you won't need the if statement anymore

quaint epoch
#

hello mina

daring olive
#

hi

quaint epoch
junior verge
#
description={message.content},
``` Why does this send my message like this:
cold sonnet
#

why did you use {}

#

makes it a set

junior verge
#

How?

cold sonnet
#

cuz that's how you define a set

#

if you want it to be an str, just don't convert it to a set

#

description=message.content,

junior verge
#

oh

#

ty

#
@commands.Cog.listener()
    async def on_message(self, message):
        try:
            if ".close" in message.content:
                pass
                
            else:
                if str(message.channel.type) == "private":
                    return
                else:
                    if message.author == self.client.user:
                        return
                    else:
                        user = await message.guild.fetch_member(int(message.channel.name))
                        emb = discord.Embed(
                            title=f"{message.author.name}#{message.author.discriminator}'s Response",
                            description=message.content,
                            timestamp= datetime.utcnow(),
                            color = discord.Color.green()
                        )
                        await user.send(embed=emb)

        except Exception as e:
            print(e)
            pass
``` How do I make it so it doesn't do this on *every* message
final iron
#

See anything wrong?

cold sonnet
#

how do you convert the channel's name to a number

junior verge
final iron
#

?

maiden fable
cold sonnet
#

and why do you fetch a member

junior verge
#

Did not really know how to do it else

junior verge
final iron
junior verge
#

oh i was in the wrong file

smoky anvil
#

Someone who knows how to make an giveaway bot with invite requirements?

junior verge
glad cradle
#

anyone use Disnake library?

maiden fable
#

yea

glad cradle
#

i need help

#

i'll send here my question

#
@commands.slash_command(description="Send the 10 latest videos of CodeWithVincent youtune channel.")
  async def latestVideos(self, inter):
  
    view = disnake.ui.View()
    item = disnake.ui.Button(
      style=disnake.ButtonStyle.blurple, 
      label="Test",
      emoji=":fast_forward:",
      custom_id="Next-btn"
    )
    view.add_item(item=item)
    msg = await inter.response.send_message(embed=embed, view=view)
    
    interaction = await self.bot.wait_for("button_click", timeout=60, check=lambda inter: item.custom_id == "Next-btn")


  @commands.Cog.listener()
  async def on_button_click(self, interaction):
    x = await interaction.original_message()
    
    embed = disnake.Embed(
      title='Yes :)'
    )

    await x.delete()
junior verge
#

@final iron It's now not working anymore as well

glad cradle
#

how to edit or delete original message interaction on_button_click

final iron
unkempt canyonBOT
#

@final iron :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | ValueError: invalid literal for int() with base 10: 'channel name'
junior verge
#

Keep getting this when typing in the ticket, it should dm the user with my response

maiden fable
#

!d disnake.Interaction.edit_original_message

unkempt canyonBOT
#

await edit_original_message(*, content=..., embed=..., embeds=..., file=..., files=..., attachments=..., view=..., components=..., allowed_mentions=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the original, previously sent interaction response message.

This is a lower level interface to [`InteractionMessage.edit()`](https://docs.disnake.dev/en/latest/api.html#disnake.InteractionMessage.edit "disnake.InteractionMessage.edit") in case you do not want to fetch the message and save an HTTP request.

This method is also the only way to edit the original message if the message sent was ephemeral.

Note

If the original message has embeds with images that were created from local files (using the `file` parameter with [`Embed.set_image()`](https://docs.disnake.dev/en/latest/api.html#disnake.Embed.set_image "disnake.Embed.set_image") or [`Embed.set_thumbnail()`](https://docs.disnake.dev/en/latest/api.html#disnake.Embed.set_thumbnail "disnake.Embed.set_thumbnail")), those images will be removed if the message’s attachments are edited in any way (i.e. by setting `file`/`files`/`attachments`, or adding an embed with local files).
final iron
#

Is essentially what you're doing

glad cradle
junior verge
#

How to fix it erm

final iron
#

Remove the line?

slate swan
cold sonnet
#

you don't convert the name to a number, in fact, you shouldn't use name but id

junior verge
slate swan
#

you shouldnt, cause that works

cold sonnet
#

even tho if you have the id, you should have the memebr object originally

glad cradle
cold sonnet
#

unnecessary f-strings are bad

glad cradle
#

like interaction has no response

junior verge
#

So what do I do to get it fixed so it doesn't do this the whole time and send the message back in dms

glad cradle
maiden fable
#

mind showing the error?

glad cradle
#

ok

final iron
junior verge
#
user = await message.guild.fetch_member(int(message.channel.name))
``` You are talking about this line, right?
final iron
#

Yes

cold sonnet
#

you are fetching a guild's member by the name of a channel

#

these two are completely unrelated

#

who do you want to send the message to

junior verge
#

To the users dm

#

It used to work like 10m ago not sure what changed

cold sonnet
#

which user

glad cradle
# maiden fable mind showing the error?
@commands.Cog.listener()
  async def on_button_click(self, interaction):
    
    embed = disnake.Embed(
      title='Yes :)'
    )

    await disnake.Interaction.edit_original_message(self, embed=embed)

AttributeError: 'SlashLatestVideos' object has no attribute '_state'

cold sonnet
glad cradle
cold sonnet
junior verge
cold sonnet
#

interaction is a disnake.Interaction

cold sonnet
#

or a member variable?

final iron
junior verge
cold sonnet
#

which user bro

junior verge
#

The one that made the ticket

cold sonnet
#

how did you store that user

#

just... show code

junior verge
#

They dm the bot, the bot makes a channel, if I type something in that channel it gets send to them

glad cradle
#
@commands.Cog.listener()
  async def on_button_click(self, interaction):
    
    embed = disnake.Embed(
      title='Yes :)'
    )

    await interaction.edit_original_message(embed=embed)

disnake.errors.InteractionNotResponded: This interaction hasn't been responded to yet

junior verge
#
import discord
from discord.ext import commands
from datetime import datetime

class Mod(commands.Cog):

    def __init__(self, client):
        self.client = client
    
    @commands.Cog.listener()
    async def on_ready(self):
        print(f"{self.__class__.__name__} Cog has been loaded\n-----")

    @commands.Cog.listener()
    async def on_message(self, message):
        try:
            if ".close" in message.content:
                pass
                
            else:
                if str(message.channel.type) == "private":
                    return
                else:
                    if message.author == self.client.user:
                        return
                    else:
                        user = await message.guild.fetch_member(str(message.channel.name))
                        emb = discord.Embed(
                            title=f"{message.author.name}#{message.author.discriminator}'s Response",
                            description=message.content,
                            timestamp= datetime.utcnow(),
                            color = discord.Color.green()
                        )
                        await user.send(embed=emb)

        except Exception as e:
            print(e)
            pass

    @commands.command()
    async def close(self, ctx):
        user = await ctx.guild.fetch_member(int(ctx.channel.name))
        await user.send("Modmail has been closed by the support team")
        await ctx.channel.delete()




def setup(client):
    client.add_cog(Mod(client))
#
import discord
from discord.ext import commands
from datetime import datetime

class Modmail(commands.Cog):
    def __init__(self, client):
        self.client = client

    @commands.Cog.listener()
    async def on_ready(self):
        print(f"{self.__class__.__name__} Cog has been loaded\n-----")

    @commands.Cog.listener()
    async def on_message(self, message):
        if str(message.channel.type) == "private":
            if message.author == self.client.user:
                return
            else:
                guild = self.client.get_guild(867086205182017536)
                channels = await guild.fetch_channels()
                channel = discord.utils.get(channels, name = str(message.author.id))

                if channel is None:
                    category = discord.utils.get(guild.categories, name="Tickets")
                    channel = await guild.create_text_channel((message.author.name),category = category)

                    await message.author.send("Modmail has been created succesfully")
                    em = discord.Embed(
                        title=f"{message.author.name}#{message.author.discriminator} created a modmail",
                        description= message.content,
                        timestamp = datetime.utcnow(),
                        color = discord.Color.dark_blue()
                    )
                    await channel.send(embed=em)
                    await channel.send("<@&868232863592620072>")

                else:
                    em = discord.Embed(
                        title=f"{message.author.name}#{message.author.discriminator} created a modmail",
                        description= message.content,
                        timestamp = datetime.utcnow(),
                        color = discord.Color.dark_blue()
                    )
                    await channel.send(embed=em)


def setup(client):
    client.add_cog(Modmail(client))
junior verge
#

yep sorry @glad cradle

zealous rover
#
 elif reaction.emoji == u"\u23E9":
        if current <len(bot.help_pages)-1:
            current += 1

    elif reaction.emoji == u"\u2197":
        if current = len(bot.help_pages)-1

    for button in buttons:
        await message.remove_reaction(button, ctx.author)

problem - ',' or '(' or ')' expected

maiden fable
cold sonnet
#

user = message.author
instead of
user = await message.guild.fetch_member(str(message.channel.name))

#

@junior verge

#
                channels = await guild.fetch_channels()
                channel = discord.utils.get(channels, name = str(message.author.id))
```this also doesn't make any sense
maiden fable
#

I just love it how people who ask for help tend to ignore many times and we just keep on pinging them haha

cold sonnet
#

unless you have a channel named after the user's id

glad cradle
#

disnake.errors.InteractionNotResponded: This interaction hasn't been responded to yet

cold sonnet
#

hm that's weird

glad cradle
#

i need to respond to an interaction?

maiden fable
cold sonnet
#

and Daxles, you make too many unnecessary API calls

#

fetching is almost never necessary

junior verge
junior verge
zealous rover
#
import ctx as ctx
import discord
import asyncio
import os

from async_timeout import timeout
from discord import message
from discord.ext.buttons import buttons
from dotenv import load_dotenv
from discord.ext import commands

load_dotenv()
TOKEN = os.getenv("TOKEN")

bot = commands.Bot(command_prefix='.', help_command=None)

@bot.event
async def on_ready():
    print("Bot is now ready to shut up discord from unwanted users")

@bot.command(pass_context=True)
async def clear(ctx, amount=10):
    channel = ctx.message.channel
    messages = []
    async for message in bot.logs_from(channel, limit=int(amount)):
        messages.append(message)
        await bot.delete_messages(messages)

#help pages
page1 = discord.Embed(title='Bot Help 1', description='Use the buttons below to navigate pages.', colour=discord.Colour.orange())
page2 = discord.Embed(title='Bot Help 2', description='Page 2', colour=discord.Colour.red())
page3 = discord.Embed(title='Bot Help 3', description='Page 3', colour=discord.Colour.green())

bot.help_pages = [page1, page2, page3]

@bot.command()
async def help(ctx):
    buttons = [u"\u23E9", u"\u23EA", u"\u2197", u"\u2196"]
    current = 0
    msg = await ctx.send(embed=bot.help_pages[current])

    await msg.remove_reaction(reaction.emoji, ctx.author)

while True:
    try:
        reaction, user = (await bot.wait_for("reaction_add", check=lambda reaction, user == ctx.author and reaction.message == msg and
                          reaction.emoji in buttons, timeout=60.0)

    except asyncio.TimeoutError:
        embed = bot.help_pages[current]
        embed.set_footer(text="Timed Out.")
        await message.clear_reactions()

    else:
        previous_page == current

    if reaction.emoji == u"\u2196":
        current = 0

    elif reaction.emoji == u"\u23EA":
        if current > 0:
            current -= 1

    elif reaction.emoji == u"\u23E9":
        if current <len(bot.help_pages)-1:
            current += 1

    elif reaction.emoji == u"\u2197":
        if current = len(bot.help_pages)-1

    for button in buttons:
        await message.remove_reaction(button, ctx.author)

    if current != previous_page:
        await message.edit(embed=bot.help_pages[current])

client.run(TOKEN)
smoky anvil
#

Someone who knows how to make an giveaway bot with invite requirements?

cold sonnet
junior verge
#

Replace what with what I am confused

smoky anvil
#

Someone who knows how to make an giveaway bot with invite requirements?

junior verge
#

you can ping me btw idm

glad cradle
#

oh it was

await interaction.response.edit_message(embed=embed)

zealous rover
cosmic agate
#

how to make a twitch live alert in discord bot?

zealous rover
junior verge
zealous rover
#

Thorowin errors

cold sonnet
#

which line is 46

#

and which is 69

zealous rover
#

umm wait

junior verge
#

Theres no line 46

glad cradle
#

can i check who pressed a button?

cold sonnet
cold sonnet
spice basalt
sharp snow
#

Hello, how would I make my bot delete its old output when the user edits their command

cold sonnet
#

its old output as in?

glad cradle
junior verge
cold sonnet
#

idk, but doesn't matter in opposition to your error

sharp snow
#

I have

async def on_message_edit(before, after):
    await bot.process_commands(after)```
But I want the bot to delete the old response before outputting the new response
spice basalt
cold sonnet
#

you have to store the old response Majixed

cold sonnet
#

did you forget the quotation marks

sharp snow
#

so for example if I say, $help, the bot sends the help page. And if I edit $help to $ban the bot should delete the help page, and execute the ban command afterwards

cold sonnet
spice basalt
cold sonnet
#

so you can use await stored_variable_of_the_message.delete()

spice basalt
#

i also have to mention myself if i change it to that and it'll also still just say my name instead of "you"

slate swan
cold sonnet
#

remove .name

sharp snow
#

Ah I see

cold sonnet
slate swan
#

your happy im here? how cutethanks 02smug

cold sonnet
#

yeah thought I wouldn't have to carry on with 5 guys

slate swan
sharp snow
#

But the thing is, I want this to be the case for every command the user runs, not just one specific command. How do I store the output of the previous command? Is there a name for it?

spice basalt
cold sonnet
#

then

#

that's bad

sharp snow
spice basalt
cold sonnet
#

completely remove that

#

that one liner

spice basalt
#

i did?

cold sonnet
#

remove that

spice basalt
#

okay

cold sonnet
#

and put your if statement back

spice basalt
#

🗿

cold sonnet
#

this without member = member or ctx.author

#

and the inappropriate words are what we don't care about in this picture

#

you can remove a return aswell

slate swan
spice basalt
#

it works now

slate swan
cold sonnet
zealous rover
#

talking about this

slate swan
maiden fable
#

!d discord.abc.Messageable.send

unkempt canyonBOT
#
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=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.10)") 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.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
slate swan
cold sonnet
slate swan
zealous rover
cold sonnet
#

and outdenting the last line

#

unindenting outdenting

slate swan
#

thats for assigning and not comparing

cloud dawn
slate swan
#

lol

zealous rover
cloud dawn
cloud dawn
#
return await ctx.send(f"{f'{member} is' if member else 'you are'} {random.choice(wai_list)}.")
slate swan
#

i love you

#

Do I need to update discord

zealous rover
slate swan
cold sonnet
slate swan
#

seems like Command is discord for some what reason

slate swan
slate swan
#

Thanks bro

cold sonnet
#

you can use the name kwarg in @bot.command() though

slate swan
#

yeah

cloud dawn
glad cradle
#

how to edit webhook when a specific button was pressed, can i use on_button_click??

cold sonnet
#
@bot.command(name="discord")
async def randomfunctionnamelmao():
    #pass
slate swan
#

use ellipses

cloud dawn
cold sonnet
#

nice

slate swan
#

its always like that you can only use singles inside of doubles and doubles inside singles

cold sonnet
#

I'm single

slate swan
#

im talking about quotes

slate swan
#

how exactly?

cloud dawn
unkempt canyonBOT
#

@cloud dawn :white_check_mark: Your eval job has completed with return code 0.

"""""""""""""""""""""
sick birch
# slate swan how exactly?

!e

print("And he said, \"its always like that you can only use singles inside of doubles and doubles inside singles\" funniest stuff I ever heard!")
unkempt canyonBOT
#

@sick birch :white_check_mark: Your eval job has completed with return code 0.

And he said, "its always like that you can only use singles inside of doubles and doubles inside singles" funniest stuff I ever heard!
slate swan
#

without the \ espFacepalm

cold sonnet
#

you have to keep those bytes

#

so use '

dull terrace
#

i am struggling to read documentation rn

slate swan
#

which

cold sonnet
#

if you save 1 000 000 000 of backslashes, you saved a gigabyte already

#

use '

slate swan
#

smort

dull terrace
#

so i'm reading this and it's obvious how this works but then i go to view

#

and im just like uhhhh

glad cradle
#

how to edit a webhook when a specific button was clicked? can i use on_button_click? (there are 3 buttons)

cold sonnet
#
@bot.event
async def on_dropdown(interaction):
    pass
``` called when any select menu is clicked
dull terrace
#

yeah i get on_dropdown

#

but it's saying to use view instead

cold sonnet
#

yeah that's better

slate swan
#

read the note

glad cradle
cold sonnet
#

yeah it says to use the callback function of the view, not this

#

cuz this is bad, callback good

slate swan
dull terrace
slate swan
dull terrace
cold sonnet
#

The same callback method that is stated above is our event

#

you can use both

#

the callback of the view would be specifically for that view

#

the event would just tell you that one of your views was clicked

slate swan
cold sonnet
#

it's like

slate swan
#

not the view

cold sonnet
#

local errors for a command and an on_command_error

#

me saying all this with just my brain, not even bothering to try it out

cold sonnet
cold sonnet
#

don't u dare tell me it's wrong

slate swan
#

which of all

cold sonnet
#

replace view with a component in every message

slate swan
#

what

cold sonnet
#

nah then it don't make sense

slate swan
#

a View is a container of components

cold sonnet
#

let's say

#

on_dropdown is called whenever a callback of a select menu is called

#

?

dull terrace
#

yeah that should be right

slate swan
#

so yes

cold sonnet
#

how does it even fetch that information

slate swan
#

what?

cold sonnet
#

how does it know when you click it without selecting an option

cosmic agate
#

how to make a twitch live alert in discord bot

#

??

slate swan
dull terrace
#

so i could essentially do

class View:
    async def interaction_check(interaction):
        #common code that runs on all interactions such as checking author of message is the interacting author

then use on_dropdown for the rest

sick birch
dull terrace
#

and whatever the button one is etc.

cold sonnet
#

nah you gotta inherit discord.ui.View

cloud dawn
cold sonnet
#

please point out the part that I should know how to read

#

😿

cold sonnet
#

oh

slate swan
#

its just a gateway events and its response body how is that hard to read?

cold sonnet
#

cuz Ion even know where to start

slate swan
#

and its formatted in json

cloud dawn
#

Pretty bad there isn't a comment whether it's a POST or GET

slate swan
cold sonnet
#

INTERACTION_CREATE

slate swan
cloud dawn
slate swan
cold sonnet
#

god I have to learn

slate swan
sick birch
#

The websocket gateway?

cold sonnet
#

"nick": null,
why even null it's not even python-like

dull terrace
#

welp, im just gonna ignore view and use the on_ methods

slate swan
sick birch
#

Connecting to it manually without a wrapper teaches you a lot

cold sonnet
#

IDK JSON

sick birch
#

But formatted as a JSON so it can be parsed by both parties

slate swan
#

this is a payload thats sent by the gateway ofc it wont be python like

sick birch
#

You can also agree on ETF iirc and use zlib compression

slate swan
obtuse ridge
#

Can anyone help me with discord_ui stuff?

sick birch
#

You need to agree on the data format on start

sick birch
obtuse ridge
#

Why cant i add View from discord-ui?
Error:

  File "main.py", line 8, in <module>
    from discord_ui import Button, view
ImportError: cannot import name 'view' from 'discord_ui' (/opt/virtualenvs/python3/lib/python3.8/site-packages/discord_ui/__init__.py)```
Code:
```py
from discord_ui import Button, view
cold sonnet
#

"username": "uyy ese hombre",
nah bro this is getting inhumane

sick birch
#

It's discord.ui

sick birch
#

Usually though you'd want to import

from discord import ui

and use ui.Button or ui.Select to not pollute the namespace

cold sonnet
#

hombre means man doesn't it

#

jesus I'm good

sick birch
#

with what?

slate swan
#

means ey that man

cold sonnet
sick birch
#

I'm confused

pliant gulch
#

So lost

slate swan
cold sonnet
#

we all are confused

hushed galleon
#

i wish the select menus on desktop actually had a submit button next to them

obtuse ridge
#
    from discord import ui, ui.Select
                              ^
SyntaxError: invalid syntax```
sick birch
#

Not quite

#

Once you import it you can use it within your code as ui.Button or whatever it is

slate swan
#

or are you referring to something else

pliant gulch
cold sonnet
#

okay so in this json, the whole d var is the interaction, then that interaction has the message with content and components and stuff

hushed galleon
sick birch
# obtuse ridge im confused
from discord import ui
class MyView(ui.View):
  ...
class MyButton(ui.Button):
  ...
class MySelect(ui.Select):
  ...
cold sonnet
#

and the message has an interaction and a view

hushed galleon
#

its so annoying cause you cant select the same option twice or 0 options

slate swan
cold sonnet
#

view has components which have components

cold sonnet
sick birch
#

Component jsons are very messy

#

I tried to make them the first day modals came out since no libs supported them yet

slim ibex
#

that is my livelihood

slate swan
cold sonnet
#

in fact, dpy is the first api I use and it's quite good for learning

obtuse ridge
#

Ive put it in but it still gives me errors

pliant gulch
#

discord API's official documentation kind of sucks

sick birch
#

I really suggest you try to set up your own connection with the websocket, it's a very good learning experience and you get an understanding of how discord's API actually works

slate swan
#

the fun part is parsing the response body thats hella messy AG_Smirk

obtuse ridge
sick birch
#

It's not discord_ui

#

Get rid of that entire line you don't need it

cold sonnet
#

import pycord doesn't exist

sick birch
#

Also why are you importing pycord AND discord

cold sonnet
#

cuz pycord uses the name discord

slate swan
cold sonnet
#

which is good, useful and understandable

spice basalt
#

i've been trying to solve this for the past 30 minutes by trying new ways but it isn't working, it isn't giving an output but it also isn't giving an error

@client.command()
async def cr(ctx, member:discord.Member=None):
  
  if member is None:
    return await ctx.send(embed = discord.Embed(title="cool rate", description = f"You are {random.randrange(101)}% Cool 😎", color = 0xffffff))
  else:
    return await ctx.send(embed = discord.Embed(title="cool rate", description = f"{member.name} is {random.randrange(101)}% Cool 😎", color = 0xffffff))
sick birch
slate swan
#

i want to wrap an api with websockets and use aiohttps websocket support

sick birch
#

Do it on discord's api

obtuse ridge
slate swan
spice basalt
sick birch
spice basalt
#

wait nevermind, i might have an idea

pliant gulch
slate swan
pliant gulch
#

like what

#

Rin codebase is pretty easy, if you know where to look for things

obtuse ridge
#

How do i update it because the new one is discord-ui Right?

pliant gulch
#

Pretty much everything is done for you already

sick birch
obtuse ridge
#

oh

cold sonnet
#
@client.command()
async def cr(ctx, member:discord.Member=None):
    await ctx.send(embed = discord.Embed(title="cool rate", description = f"{'You are' if member is None else f'{member.name} is'} {random.randrange(101)}% Cool 😎", color = 0xffffff))
slate swan
obtuse ridge
pliant gulch
obtuse ridge
sick birch
#

@pliant gulch I meant to ask you but, you are you heartbeating and polling for websocket messages concurrently using async? I always had trouble with that. Create_task?

slate swan
pliant gulch
slate swan
#

💀

sick birch
pliant gulch
obtuse ridge
#

kk

sick birch
pliant gulch
cold sonnet
#

if you don't have an error handler, well....

sick birch
#
heartbeat_task = create_task(heartbeater())
poll_task = create_task(poller())

await heartbeat_task
await poll_task

like that for instance

#

It would get hung up on await heartbeat_task because it's a while true loop

#

And it never returns

#

Without awaiting it the programs quits after creating the tasks

pliant gulch
#

You would have to do ```py
hearbeat_task = create_task(...)
await poller()

cold sonnet
#

lmao

pliant gulch
#

You don't need to await for the heartbeat task, logically

#

So you don't need to await

sick birch
#

You can call it without await?

pliant gulch
#

Yes

sick birch
#

But it's a coroutine

pliant gulch
#

You don't need to await it in this case though

spice basalt
#

i'm just gonna sleep and continue when i wake up

sick birch
#

You'd get an error wouldn't you?

hushed galleon
#

yea the point of create_task is that it gets scheduled in the event loop, so at any opportune moment while you're awaiting something else, your task can run

pliant gulch
sick birch
#

Yeah since heartbeating is only done like every 45 seconds so it's like 99% IO

pliant gulch
#

So, just schedule it, then await your poll

sick birch
#

Oh. that makes more sense. Before I was trying either not awaiting either or awaiting both of them

#

Never occured to me to just await the polling

pliant gulch
#

If that was what you were talking about that is ^

hushed galleon
#

hmm maybe ill look into connecting to the gateway too, always wanted to learn more about sockets

pliant gulch
#

Fork rin and finish it for me 🙏

sick birch
#

Ah okay. Thanks for that, I'll try your approach later today 😄

obtuse ridge
#

Im pretty sureive updated it now but i still get the error

#
  File "main.py", line 5, in <module>
    import discord.ui as disc
ModuleNotFoundError: No module named 'discord.ui'
 ```
slate swan
pliant gulch
#

No I'm working on cursecord now

slate swan
#

you left the lib in the ground so finish it

pliant gulch
#

April fools joke, better done then never

slate swan
pliant gulch
#

Finish it for me then

slate swan
#

🏃‍♂️

slate swan
wide thunder
#

long time no see

pliant gulch
#

2 busy procrastinating

slate swan
#

fine😡

pliant gulch
#

All you really have to do is add models

slate swan
#

and you already did base models right AG_ChikaStunned

pliant gulch
hybrid mural
#

sqlite doesnt work with bots right?

pliant gulch
slate swan
#

ill look into them

wide thunder
#

what's cursecord

pliant gulch
slate swan
pliant gulch
# wide thunder what's cursecord

My late april fools joke wrapper ```py
import cursecord

async def main() -> None:
guild = cursecord.Guild.precreate(id=...)

async with cursecordCursedClient(....) as (client, gateway, rest):

    @gateway.on(cursecord.MESSAGE_CREATE)
    async def message(message: cursecord.Message) -> Iterator[str]:
        yield f"I got a message from {message.author}"

    @guild.on(cursecord.GUILD_DELETE)
    async def deleted(guild: cursecord.Guild) -> None:
        print("deleted")

 await gateway.setup()

asyncio.run(main())

slate swan
#

there's asyncronous sqlite libraries right

#

!pypi aiosqlite

unkempt canyonBOT
slate swan
#

yeah

hybrid mural
wide thunder
#

ohh

slate swan
#

aiosqlite is sqlite

slate swan
hybrid mural
#

ah ok

slate swan
#

pep 9001 > pep8

#

see what i did with the space after the word pephehe

pliant gulch
#

I will be attempting to make cursecord work later

#

Haven't finished procrastinating yet

slim ibex
#

'o

#

pog

slate swan
pliant gulch
#

Idk

#

But I'd better make it ratelimit sane

slate swan
#

no dont make onelemon_smirk

cosmic agate
#

how to make a twitch live alert in discord bot

#

please this is the third time im asking

sick birch
spice adder
#

Hey quick question, is there a reason why slash commands aren't showing up? I figured I might be doing something wrong, so I tried one of those templates, but nothing pops up, no errors or anything.

from discord import app_commands

@tree.command(guild=discord.Object(id=507364684924452896))
async def slash(interaction: discord.Interaction, number: int, string: str):
    await interaction.response.send_message(f'{number=} {string=}', ephemeral=True)
sick birch
#

Did you sync?

spice adder
#

Oh?

sick birch
#

making a slash command only updates the local tree

#

You need to sync those changes over discord

spice adder
#

Oh, I see, how would I do that?

sick birch
#

In your on ready, you can do like tree.sync()

#

!d discord.app_commands.CommandTree.sync

unkempt canyonBOT
#

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

Syncs the application commands to Discord.

This must be called for the application commands to show up.

Global commands take up to 1-hour to propagate but guild commands propagate instantly.
sly hamlet
#

When using buttons is there a way to just view one button instead of the entire class of buttons?

sick birch
#

What do you mean?

slate swan
#

i almost give up bro

#

i have been trying to learn to code

#

not going as planned

sick birch
#

When does it ever

#

You're not alone, happens to almost all of us

slate swan
#

like bro i can only do print command

sick birch
#

That was all of us at one point or another

spice adder
#

I'm assuming something like

await tree.sync(guild=None)
``` this?
sick birch
#

Specify a guild

slate swan
#

Yeah maybe but idk how to learn utube doesn't work

sick birch
#

Global slash commands can take up to an hour to propagate

sick birch
#

Youtube sucks for coding tutorials

slate swan
#

Howu learn?

sick birch
#

You do all these tutorials and follow along, then the times comes to do something yourself and you have no idea what to do

obtuse ridge
#

does anyone know how to make the bot DM a new member ?

sick birch
#

That's because you just copy down what the youtuber says without really thinking about it. Even if you think about it it isn't very efficient and you're not going to end up learning anything

sick birch
obtuse ridge
#

thanks

slate swan
#

i don't think im gonna learn it

sick birch
#

You will, trust me

#

But not off youtube tutorials

slate swan
#

then ?

sick birch
#

Those will never work

#

Attempt a project. Keep googling until you get it. Over time you start to understand how to do things

#

Whatever you do, stay off youtube tutorials

pliant gulch
#

I learned by reading source code 👁️👁️

sick birch
#

That's how many of us learn. By doing projects we like, breaking things, fixing things, breaking things, deleting the whole project, starting over, breaking it

sick birch
sly hamlet
obtuse ridge
#

is it like this?

sick birch
#

Find a professional project on github written in python, go looking around the code and see how others do it

slate swan
#

k

pliant gulch
#

Make sure it isn’t a mega repo

#

You’d just get confused even more

sick birch
sly hamlet
#

But that just has one button in the class and there have five in mine and I just want to post one for that single command

sick birch
slate swan
#

pls help me with this

sick birch
#

Or do it dynamically by subclassing BOTH view AND button

slate swan
#

Why does it say this

sly hamlet
#

Guess I got some research to do on subclasses

sick birch
#

Maybe jumping in head first to that isn't the best idea when you said you only know how to make print statements

pliant gulch
#

Meaning one repo with all their stuff in it, etc

slate swan
#

@sick birch

cold sonnet
slate swan
sick birch
sick birch
cold sonnet
#

"This interaction failed" is weird cuz it legit gives no information

#

but ig it's worth a try defering

sick birch
cold sonnet
#
    async def callback(self, interaction):
        await interaction.response.defer()
sick birch
#

There's only one way for an interaction to fail, that is your bot didn't respond to an interaction, so no information is necessary on discord's side

slate swan
sick birch
#

why that many indents

spice adder
slate swan
#

wth is that

cold sonnet
#

what where are the callbacks of those

slate swan
sick birch
cold sonnet
#

indents?

#

what are indents?

slate swan
sick birch
#

I mean you asked what that is. It's code, for those pictures you sent us

sly hamlet
cold sonnet
#

uh

sick birch
#

Not quite that's a regular class

pliant gulch
#

class Test(Counter): ...

cold sonnet
#

and bad syntax

cold sonnet
#

and why didn't you use them

sick birch
#

I don't think that's their code

sly hamlet
slate swan
#

Yeah it's the code for the pictures i sent

cold sonnet
#

yeah that seems good

sick birch
#

They said earlier they were new and only knew how to do print statements. Later they sent a few pictures of a verified bot functionality, then that code matches up with it

cold sonnet
#

Music doesn't seem that good, but this is python

sly hamlet
#

This goes underneath the current clash right

sick birch
#

If I'm to guess that code is for a verified bot which is very disappointing

cold sonnet
#

okay if that code is for a verified bot I don't know what I'll do

slate swan
#

it's my own

sick birch
# slate swan

Oh nevermind, I was looking at the wrong bot in this picture

cold sonnet
#

we were rude

sick birch
#

Nah. Constructive critism

sly hamlet
#

Oh I don't know why I wanted to make parrot noise music commands LOL this is stupid

cold sonnet
#

the first four lines of the command can be replaced with

#

if "ticket" in channel.name:

#

you saved 3 variables

slate swan
cold sonnet
#

yes

sly hamlet
sick birch
#

I only recommend making extra variables and wasting memory if it improves readibility. In this case it reduces readibility AND wastes memory

sick birch
obtuse ridge
#

Ive just got an error and i dont understand it

quaint epoch
#

hey someone tryin' to check if a bot made a ticket?

#

(is the ticket a channel?)

sly hamlet
cold sonnet
#

he says cool

obtuse ridge
# obtuse ridge Ive just got an error and i dont understand it
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 300, in static_login
    data = await self.request(Route('GET', '/users/@me'))
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 254, in request
    raise HTTPException(r, data)
discord.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 "main.py", line 211, in <module>
    client.run(TOKEN)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 723, in run
    return future.result()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 702, in runner
    await self.start(*args, **kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 665, in start
    await self.login(*args, bot=bot)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 511, in login
    await self.http.static_login(token.strip(), bot=bot)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 304, in static_login
    raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.
 ```
sick birch
# sly hamlet ??

Are you sure you want to do multiple inheritance? I've seen that maybe twice in my life

sick birch
sick birch
#

What's not to understand about that?

quaint epoch
sly hamlet
sick birch
#

I'm guessing you were looking at the top with the 401 unauthorized

sly hamlet
#

But it also needs to be a subclass

cold sonnet
sick birch
sick birch
cold sonnet
#

well you can do that if you're really cool

#

like CulannDogGaming

sick birch
#

Also need to make sure you NEED it

#

No point in multiple inheritance if you don't need it. I guess that's true for most things so it's redundant

vocal plover
#

There's no point doing it unless you actually need it, often it will just cause cryptic error messages like "cannot create a consistent mro", usually just instantiating the other class as an attribute is fine

sly hamlet
obtuse ridge
#

Ho do i make it so that when the user clickes on a reaction role it DMs Them?

sly hamlet
sick birch
quaint epoch
cold sonnet
pliant gulch
#

Wouldnt it make more sense to just have a class that utilises Counter instead of inheritance?

sick birch
sly hamlet
#

It's for the button subclass

obtuse ridge
sick birch
unkempt canyonBOT
#
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=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.10)") 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.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
cold sonnet
#

you have payload, right? @obtuse ridge

vocal plover
#

it would make more sense, from the very limited info I have, perhaps to do this:

class Music(ui.View):
  def __init__(self, ...):
    self.counter = Counter()
sick birch
#

iirc the person had a view with 5 buttons, but only wanted to send one of those on a specific occasion

#

So I can see why they think that's necessary

#

You can either make a seperate subclass just for that one button, or subclass both button and view and make it dynamic

obtuse ridge
cold sonnet
#

show us what you have elio

sick birch
#
class MyButton(ui.Button):
  def __init__(self, multiple: bool):
    if multiple:
      self.add_item()
      self.add_item()
      self.add_item()
      self.add_item()
    else:
      self.add_item()
  @discord.ui.button(...)
  async def callback(...):
    ...
obtuse ridge
cold sonnet
#

okay... that's not a reaction role

#

and you need await

obtuse ridge
sly hamlet
#

Another problem I was having on the why I wanted it inside the music classes because I have my q define in there but one of the buttons requires it

cold sonnet
#
@client.event
async def on_member_join(member):
    await member.send("Example")
#

perhaps

obtuse ridge
#

ill try it now

#

it doesnt send anything

cold sonnet
#

what did you do

obtuse ridge
#

join the sever

cold sonnet
#

hm

#

you might need members intents

#

!intents

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.

obtuse ridge
#

whats that

cold sonnet
#

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)
#

this is the only part you gotta read

obtuse ridge
#

so do i add that to my code?

cold sonnet
#

you gotta add stuff

#

not everything

obtuse ridge
#

Like what?

cold sonnet
#

you already have most

obtuse ridge
#

ohh

#

so add this

cold sonnet
#

yes

#

and , intents = intents

#

in your Bot constructor

#

also import Intents

slate swan
#

anyone know a good api for nsfw without uh.. cartoons

cold sonnet
#

what the heck does that have to do with us

slate swan
#

just uh

#

answer the question

obtuse ridge
#

so now do i try it?

cold sonnet
#

if you did it right, yes

cold sonnet
obtuse ridge
#

Wooooo, it worked

cold sonnet
#

nice 👍

slate swan
#

im tryna make a discord bot for a huge community and the owner requested that xD

cold sonnet
#

ew

slate swan
#

you must be incredibly young if thats disgusting to you

cold sonnet
#

I'm

#

enough aged

slate swan
#

youre gonna do/see it more than likely in ur life

cold sonnet
#

now he's giving life lessons

obtuse ridge
#

hahah

slate swan
#

this isnt the point, do u know one or not lol

cold sonnet
#

no

sly hamlet
slate swan
sly hamlet
#

It relates to Discord bots though they're just going to tell me to come here

cold sonnet
#

tell them we have absolutely no idea

obtuse ridge
#

how do i get this to work?

dull terrace
#

trying to respond to a button interaction in disnake with this

obtuse ridge
#
@client.event
async def on_member_join(member):
    await member.send(embed=embed)

embed=discord.Embed(title=" You have been successfully verified!", description="Thank you for joining - we hope you enjoy your stay.", color=0x00ebff)
dull terrace
#

keep getting disnake.errors.InteractionNotResponded: This interaction hasn't been responded to yet

#

disnake.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook

cold sonnet
#

and switch it with member.send so it's in a good order

#
@client.event
async def on_member_join(member):
    embed=discord.Embed(title=" You have been successfully verified!", description="Thank you for joining - we hope you enjoy your stay.", color=0x00ebff)
    await member.send(embed=embed)
dull terrace
#

interaction.message.edit works as it should but obviously doesn't respond so it gives the interaction failed thing

obtuse ridge
#

ok ill try thanks

cold sonnet
#

Imma look it up for you

#

!d discord.InteractionResponse

unkempt canyonBOT
#

class discord.InteractionResponse```
Represents a Discord interaction response.

This type can be accessed through [`Interaction.response`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.Interaction.response "discord.Interaction.response").

New in version 2.0.
quaint epoch
#

!d disnake.Interaction.response

unkempt canyonBOT
#

Returns an object responsible for handling responding to the interaction.

A response can only be done once. If secondary messages need to be sent, consider using followup instead.

obtuse ridge
#

it didnt send anything

cold sonnet
#

!d disnake.InteractionResponse.edit_message

unkempt canyonBOT
#

await edit_message(*, content=..., embed=..., embeds=..., file=..., files=..., attachments=..., allowed_mentions=..., view=..., components=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Responds to this interaction by editing the original message of a component interaction or modal interaction (if the modal was sent in response to a component interaction).

Changed in version 2.5: Now supports editing the original message of modal interactions.

Note

If the original message has embeds with images that were created from local files (using the `file` parameter with [`Embed.set_image()`](https://docs.disnake.dev/en/latest/api.html#disnake.Embed.set_image "disnake.Embed.set_image") or [`Embed.set_thumbnail()`](https://docs.disnake.dev/en/latest/api.html#disnake.Embed.set_thumbnail "disnake.Embed.set_thumbnail")), those images will be removed if the message’s attachments are edited in any way (i.e. by setting `file`/`files`/`attachments`, or adding an embed with local files).
cold sonnet
#

get documentationed

dull terrace
obtuse ridge
#

it didnt send anything

quaint epoch
cold sonnet
obtuse ridge
#
@client.event
async def on_member_join(member):
    embed=discord.Embed(title=" You have been successfully verified!", description="Thank you for joining - we hope you enjoy your stay.", color=0x00ebff)
    await member.send(embed=embed)
#

This it right?

cold sonnet
#

should definitely be

obtuse ridge
#

nope

vale wing
#

@obtuse ridge what are you trying to do

obtuse ridge
#

get the bot to dm new members

#

but using an embed

cold sonnet
#

did you change another part of the code

obtuse ridge
vale wing
#

Sry wrong mention

#

Anyway do you have an error handler

#

on_command_error event

cold sonnet
#

I don't think he does bro

vale wing
#

There can be no other issues rather than simple DM failure

#

Which can get eaten by a bad error handler

cold sonnet
#

for what reason

gilded zephyr
#

How can I manually raise UserInputError so that my global error handler handles it?

cold sonnet
#

disabled DMs?

vale wing
#

Yes

#

I would surround such construction with try-except

hushed galleon
vale wing
gilded zephyr
#

Nvm found it, thanks 👍

sly hamlet
#

Would globally defining it help me?

hard trail
#
@bot.event
async def on_member_join(member):
  welcome_channel = bot.get_channel(933181947700732004)
  await welcome_channel.send(f"{member.mention} has joined us!")
  await member.send("Welcome!")```
#

It's not doing anything

vale wing
#

I can't think of anything else

hushed galleon
#

its pretty easy to get it wrong the first time

feral lichen
#
@bot.command()
@commands.has_role("Franchise Owner")
async def Promote(ctx, user: discord.Member):
    guild = ctx.guild

    GM = discord.utils.get(guild.roles, name="General Manager")
    HC = discord.utils.get(guild.roles, name="Head Coach")
    Nor = discord.utils.get(guild.roles, name="Houston Texans")

    if Nor in user.roles and not HC or GM:
        await user.add_roles(HC)
        await ctx.send("Promoted to Head Coach!")

    elif HC in user.roles:
        await user.add_roles(GM)
        await user.remove_roles(HC)
        await ctx.send("Promoted to General Manager!")

    elif GM in user.roles:
        await ctx.send("Cannot go any higher than General Manager!")
``` Okay so im having an issue when i do ~promote @muted notch er it works and promotes them to Head Coach but if i do it again (~promote @muted notch er) it does the first if statement and not elif, can anyone tell me whats wrong?
vale wing
#

!or

unkempt canyonBOT
#

When checking if something is equal to one thing or another, you might think that this is possible:

if favorite_fruit == 'grapefruit' or 'lemon':
    print("That's a weird favorite fruit to have.")

While this makes sense in English, it may not behave the way you would expect. In Python, you should have complete instructions on both sides of the logical operator.

So, if you want to check if something is equal to one thing or another, there are two common ways:

# Like this...
if favorite_fruit == 'grapefruit' or favorite_fruit == 'lemon':
    print("That's a weird favorite fruit to have.")

# ...or like this.
if favorite_fruit in ('grapefruit', 'lemon'):
    print("That's a weird favorite fruit to have.")
vale wing
#

Same for and

feral lichen
#

mk thanks

vale wing
#

Pretty sure you meant the first condition to do something else

hard trail
#
@bot.command(help="Moderator/Admin Command")
async def kick(ctx, user: nextcord.User, *, reason=None):
  guild = ctx.guild
  myEmbed3 = nextcord.Embed(title='User Kicked Successfully!', description = f"**{user}** has been kicked")
  myEmbed4 = nextcord.Embed(title=f'Kick Information for {user}', description = f"**{user.mention}** has been kicked by Admin/Moderator: **{ctx.author.mention}** because **{reason}**", timestamp = datetime.datetime.utcnow())
  myEmbed4.set_footer(text=f'User ID: {user.id}')
  myEmbed5 = nextcord.Embed(title=f'Your Kick from {guild}', description = f"You were kicked from {guild} because **{reason}**")
  myEmbed5.set_footer(text=f'You were banned by Admin/Moderator: {ctx.author}')
  myEmbed6 = nextcord.Embed(title='This User is a Admin/Moderator', color = nextcord.Color.red())
  if user.guild_permissions.manage_messages:
    await ctx.send(embed=myEmbed6)
    return
  else:
    if ctx.author.guild_permissions.kick_members:
      await ctx.send(embed=myEmbed3)
      await guild.kick(user=user)
      log_channel = bot.get_channel(875544805856407573)
      await log_channel.send(embed=myEmbed4)
      await user.send(embed=myEmbed5)```
#

What's wrong

vale wing
#

Typehint it with nextcord.Member, the User is a different thing

hushed galleon
#

a User object isnt tied to a guild, so you cant access their guild_permissions

quaint epoch
#

it doesn't exist

feral lichen
vale wing
#

It is with or. So basically you have 3 tied conditions

(Nor in user.roles) and (not HC) or (GM)```
The third condition will always be `True` unless it is `None`
#

Afaik the "and" goes before "or"

lone hare
#

hi guys

#

how to host discord bot

vale wing
#

Using VPS

lone hare
#

i dont have one

vale wing
#

Ik this is not a detailed answer lol

quaint epoch
vale wing
#

Although there are some free options

slate swan
lone hare
#

let me change the question

#

how to host discord bot FOR FREE

vale wing
slate swan
#

mimu_salute_yessir 😔

vale wing
gilded zephyr
#

Do you guys generally have your bot automatically delete error messages after a few seconds?

feral lichen
lone hare
glad cradle
#

how could I make a dynamic menu with two buttons 'previous' and 'next' with callback, I would have to edit the webhook 10 times and it should go back and forth, how can I do this?

gilded zephyr
#

Would users get annoyed

vale wing
# lone hare give bro

https://aws.amazon.com/ sign up here, create new EC2 instance with ubuntu, connect to it and do some setup https://gist.github.com/Exenifix/a8aa68a4976389757ff3121e6daadcf6

Gist

How to setup Ubuntu 20.04 server for hosting python discord bots - gist:a8aa68a4976389757ff3121e6daadcf6

hard trail
#
@bot.command(help="Moderator/Admin Command")
async def unban(ctx, user: nextcord.Member, *, reason=None):
  guild = ctx.guild
  myEmbed3 = nextcord.Embed(title='User Succesfully Unbanned', description = f"**{user}** has been unbanned!")
  myEmbed4 = nextcord.Embed(title=f'Unban Information for {user}', description = f"**{user.mention}** has been unbanned by Admin/Moderator: **{ctx.author.mention}** because **{reason}**")
  myEmbed4.set_footer(text=f'User ID: {user.id}')
  myEmbed5 = nextcord.Embed(title=f'Your Unban from {guild}', description = f"You were unbanned from {guild} because **{reason}**", timestamp = datetime.datetime.utcnow())
  myEmbed5.set_footer(text=f'You were unbanned by Admin/Moderator: {ctx.author}')
  if ctx.author.guild_permissions.ban_members:
    await ctx.send(embed=myEmbed3)
    await guild.unban(user=user)
    log_channel = bot.get_channel(879095317771997246)
    await log_channel.send(embed=myEmbed4)
    await user.send(embed=myEmbed5)

@unban.error
async def unban_error(ctx, error):
  if isinstance(error, commands.MissingPermissions):
    embed = nextcord.Embed(title='Missing Permissions', description = "You don't have the permissions! You need the `ban members` permissions", color = nextcord.Color.red())
    await ctx.send(embed=embed)