#discord-bots

1 messages · Page 248 of 1

rugged shadow
#

put the interaction parameter before the button?

frozen flame
#

why am i not not eligible for the Active Developer Badge although i have slash commands?

north kiln
#

You have to claim it in dev portal

frozen flame
#

it says i am not eligible

north kiln
#

You will be eligible if you have used it once

#

Contact discord then

frozen flame
#

used what

#

the commands or the bot

north kiln
#

Used slash command?

frozen flame
#

works on server of 3 ppl?

north kiln
#

Doesn't matter

hearty spindle
#

anyone know how to do this bot its on danish tho

#

its a ticket bot

north kiln
#

Have you ever made a bot before?

vale wing
#

I still can't memorise what order each lib has haha

vale wing
frozen flame
vale wing
vale wing
#

Github is the way to go then

hearty spindle
#

Yeah oka

forest hatch
#

can u help me guys, my bot cannot leave the voice channel if the voice channel's name contain emoji on it. i'm just start learning to make discord bot

here is the code :

client =  commands.Bot(command_prefix = '!', intents =discord.Intents.all())

@client.event #starting the bot
async def on_ready():
    print("success :  now bot is connected to discord")
@client.command()
async def join(ctx):
    if ctx.author.voice is None:
        await ctx.send("you are not in a voice channel")
    channel = ctx.author.voice.channel
    if ctx.voice_client is None and "mig" not in channel.name:
        await channel.connect()
        await ctx.send(f"joined {channel}")
        
    else:
        await ctx.vocie_client.move_to(channel)
        await ctx.send(f"moved to {channel}")
        
@client.command(name='leave')
async def leave(ctx):
    voice_client = ctx.message.guild.voice_client
    if voice_client.is_connected():
        await voice_client.disconnect()
        await ctx.send('Bot left the voice channel')
    else:
        await ctx.send("The bot is not connected to a voice channel.")
north kiln
#

Any errors?

forest hatch
#

no error

forest hatch
vale wing
#

Make sure you are using this account on dev portal too

vale wing
frozen flame
vale wing
#

It should either throw an error (unless your error handler is too hungry and eats them) or respond with "not connected to voice channel"

vale wing
#

Bro what it blocked discord devs server invite

#

Cmon the heck

hollow osprey
#

there you go

vale wing
#

@hollow osprey why is it blocked tho

hollow osprey
#

¯_(ツ)_/¯

#

I'll check

vale wing
#

👍

frozen flame
vale wing
hearty spindle
#

Anyone got a ticket bot with buttons i can get

unkempt canyonBOT
#

examples/basic_bot.py lines 19 to 21

@bot.event
async def on_ready():
    print(f"Logged in as {bot.user} (ID: {bot.user.id})")```
white citrus
slate swan
#

here is example event called on_ready

shrewd apex
slate swan
#

if you want to use that event in a cog instead main file you can use @nextcord.ext.commands.Cog.listener() decorator

white citrus
crimson coyote
#

!pastebin

unkempt canyonBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

hearty spindle
shrewd apex
#

slash command may have another event

#

gist of it is no different from on_ready except it has a positional parameter

shrewd apex
hearty spindle
#

yeah okayy

shrewd apex
#

also python is not the only language that can be used so if u know other languages feel free to use them

hearty spindle
#

Im only good at LUA

slate swan
#

say less

warm cairn
#

Anyone here that deploy a discord bot throughout docker before?

sour sand
#

burp

warm cairn
#

I'm stuck with an error called open /dev/ptmx: no such file or directory

slate swan
#

I made a ticket discord bot and when a user opens a ticket, i made a code so there is a close button, but there's not one. There is no errors.

north kiln
#

send your code?

slate swan
north kiln
#

do you want to add the button after user selects?

#

might have to subclass your views

#

or define another callback for it

slate swan
#

i want it here

north kiln
#

attach another view with the button to that message then

#

you didn't do that in your message

slate swan
#

i have an error

#
Traceback (most recent call last):
  File "/home/runner/Atomic/venv/lib/python3.10/site-packages/discord/ui/view.py", line 427, in _scheduled_task
    await item.callback(interaction)
TypeError: ticketcallback() got an unexpected keyword argument 'view'
north kiln
#

your ticket callback didn't define any kwargs

slate swan
#

wdym

north kiln
#

async def ticketcallback(interaction):

slate swan
#

yeah?

north kiln
#

the function isn't accepting keyword arguments

#

what did you do

slate swan
#

i didnt change something there

#

the only thing i did

#

is

#

in async def ticket(ctx): i replaced button.callback = ticketcallback with button.callback = partial(ticketcallback, view=View(timeout=None))

north kiln
#

you are calling ticket callback with the view argument

#

which isn't in its parameters

slate swan
#

should i do async def ticketcallback(interaction, view):?

north kiln
#

yes

#

but I am not sure how that relates to your issue

north kiln
slate swan
#

same error but on different function

#
Traceback (most recent call last):
  File "/home/runner/Atomic/venv/lib/python3.10/site-packages/discord/ui/view.py", line 427, in _scheduled_task
    await item.callback(interaction)
TypeError: ticketcallback() missing 1 required positional argument: 'view'
#

i cant find ```

await item.callback(interaction)```

north kiln
#

remove view= then

#

I don't really know how positional and keyword stuff works

warm cairn
#

docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: open /dev/ptmx: no such file or directory: unknown.
Anyone can help me with this?

Dockerfile error

slate swan
north kiln
#

in your function call

slate swan
slate swan
north kiln
#

ok I think you didn't change your select callback

#

forget about all these things first

slate swan
#

k

north kiln
#

and make a new view with the cancel button attached to message in channel.send

slate swan
#
button = Button(label="❌ Close", style=discord.ButtonStyle.red)
    async def close_callback(interaction):
        await channel.delete()
        await interaction.response.send_message("Ticket closed successfully.", ephemeral=True)
    button.callback = close_callback
    view.add_item(button)
#

isnt this working?

north kiln
#

no

slate swan
#

i fixed the "this interaction failed"

north kiln
#

firstly, you added the button before the view is even defined

slate swan
#

but theres no button

north kiln
#

second you have to attach the view to your message

#

they are different messages

#

the one sent by the command and the one sent once a ticket is created

#

so you have to attach another view

slate swan
#

k

#

i saw the code in a yt tutorial

#

can you make the code as an example?

north kiln
#
delete_view = View()
delete_view.add_item(button)
.
.
.
await channel.send(..., view=delete_view)
slate swan
north kiln
#

yes

slate swan
#

should i add the button = ... inside the function?

north kiln
#

no

#

you attach a button to a view

#

then send the view

slate swan
#
button = Button(label="❌ Close", style=discord.ButtonStyle.red)
    async def close_callback(interaction):
        await channel.delete()
        await interaction.response.send_message("Ticket closed successfully.", ephemeral=True)
        delete_view = View()
        delete_view.add_item(button)
        .
        .
        .
        
        await channel.send(..., view=delete_view)
#

like that?

slate swan
#

If you expect it to work with those ... I'd be interesting

glossy heart
#

how do i make bots show that one like color line thing on the left?

#

like this

vocal snow
#

Those are called embeds

#

You make an instance of discord.Embed and pass it to the embed kwarg of Messageable.send

sick birch
#

!d discord.Embed

unkempt canyonBOT
#

class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

x == y Checks if two embeds are equal.

New in version 2.0...
sick birch
#

Supporting documentation ^

sour sand
#

so is it good now ?

#

(~ ∞ languages supported)

potent spear
sour sand
#

yea ik

potent spear
# sour sand yea ik

if codeblocks are also perfectly parsed, then it's perfectly fine
*cti py print("hello world!")

sour sand
#

you want me to do the command ?

#

and also wich language

potent spear
#

ah, I get it, the first argument of the command is the language

#

and all that follows is the code, so I want to see that in codeblocks
if it shows it parsed correctly in the image, then you're all set I guess

sour sand
potent spear
#

that's not in codeblocks though

#

+cti c#

using System;

namespace HelloWorld
{
  class Program
  {
    static void Main(string[] args)
    {
      Console.WriteLine("Hello World!");    
    }
  }
}```
#

if you want to copy it exactly:
+cti c#
```
using System;

namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
```

sour sand
#

@potent spear

#

idk if its good, i dont do c#

potent spear
sour sand
potent spear
sour sand
#

dont even know what that is

potent spear
#

this is a codeblock

potent spear
potent spear
unkempt canyonBOT
#
Formatting code on discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

sour sand
#

is it even useful ??

potent spear
#

ofcourse it is

sour sand
#

just on discord dude

potent spear
#
print("Isn't this a lot more readable code?")

class Poop:
  def __init__(self, person_pants):
      # ...

instead of this terrible thing
print("Isn't this a lot more readable code?")

class Poop:
def init(self, person_pants):
# ...

potent spear
sour sand
#

yes but wdc on the image its right soo

#

just the command is unreadable but the ilmage result is ok

potent spear
#

it's your command, I mean, you can at least try and see if codeblocks get parsed correctly...

sour sand
#

it dosent i sai you

potent spear
sour sand
#

said

potent spear
sour sand
#

i personally dont, ik i asked if it missed something but its a way more practical to just copy paste the code instead of puting the "`````", the code name, close it, its long dude

potent spear
#

definitely not for developers, I'm also quite sure this is messed up if you were to do it on mobile

sour sand
#

bro who codes on mobile

potent spear
#

you'd freak out if you were to see some forum screenshots...

sour sand
#

i dont want to dude

#

what a mess

#

imagine coding on a 6inches iphone 💀

noble abyss
#

anyone knows how to fix this from happening
[2023-06-02 19:41:13] [WARNING ] discord.gateway: Shard ID None heartbeat blocked for more than 10 seconds.

sour sand
noble abyss
#

they told me requests was being blocked

#

and to replace it if aiohttp

sleek cedar
#

Hello, I need suggestions for commands for my discord bot. My server is about a Roblox game studio. So far I got these commands.

formal basin
#

to make an announcement

sleek cedar
formal basin
#

hi command

sleek cedar
#

just say hi?

formal basin
#

yes

#

auto mod]

#

kick command

#

time out command

#

and un time out command

#

clear command

#

to purge the messages

sleek cedar
#

I already use wick for moderation so I don't any moderation commands currently. I might switch over some day but Wick is good at moderation.

formal basin
#

oh. ok

sleek cedar
#

@formal basin and more suggestions xD

#

any

formal basin
#

no

sleek cedar
#

ok

sleek cedar
#

ok

sour sand
sleek cedar
#

name them pls

#

oo wow

#

ty

sour sand
#

these are easy, practical and a little bit inovating (+cti, +ld, +lock)

sleek cedar
#

indeed ty

sour sand
#

Either, you can ask GPT for creative commands

sleek cedar
sour sand
#

yea

sleek cedar
#

forgot about that 💀

sour sand
#

i dont, nice for homework 💀

sleek cedar
#

lol bro

#

💀

sour sand
#

thats usefull fr

scenic pike
#

How can i create this?

unkempt canyonBOT
slate swan
#

You will not get help to violate Discord's Terms of Services, automating your user account will lead to your account getting terminated by Discord.

quartz viper
#

Hello, I'm trying to handle buttons with "discord.ui.view" but I can't combine them with "cogs", how can I do this with both classes?

vocal snow
#

what do you mean you cannot combine them with cogs? Views and Cogs are completely seperate things

quartz viper
#

Maybe I'm explaining myself wrong but I'm having trouble using both, I have a button on an embed but when I click on it the interaction fails

vocal snow
#

how are you responding to the interaction?

swift acorn
#

Hello I need some help, in my on_member_join function I am tracking invites and also sending a welcome embed

Until now I didn't have the welcome embed implemented, and invite tracking was working fine. Right after adding welcome embed, it works fine, but the invite tracking isn't working.

I tried to remove the welcome embed and then test the invite tracking and it worked

https://paste.pythondiscord.com/udoruwatuy

#

I'm not sure how the welcome embed is breaking the invite tracking because it doesn't have any errors, nothing in the console, the invite tracking embed just doesn't send

potent spear
tired pine
#

I saw a message in the discord.py server from 2 years ago and noticed you were there as well haha

potent spear
#

I'm in quite some help servers, that's a fact

vocal snow
#

He is truly ever-present and all-knowing 🙏

#

polar opposite of @smoky sinew

potent spear
smoky sinew
maiden fable
#

And I'm never-present and none-knowing

smoky sinew
#

i can't figure it out

maiden fable
#

Mix of Python and JS with a higher emphasis on Python

smoky sinew
#

if sad() == true:

slate swan
#

OOP at it's max

maiden fable
dry kelp
#

mudkip i just went with the easier solution

formal basin
#

how can i make a welcome bot for different servers

#

i have db

dry kelp
#

basically i can't set the channel id due to this failing row

raw quail
#

The select option works well in discord, but when I click the select menu in the option, it says 'The interaction failed' from bot. may i know what i missing?

smoky sinew
# formal basin how can i make a welcome bot for different servers

a cool thing would be to have a setup command that server owners can run where you could run something like !welcome setup Welcome {mention}! You are the {number} member to join the server! and it would add the guild id and message to the database, then when a member joins it could say something like py await member.send(welcome_message.format( mention=member.mention, number=f"{guild.member_count}th" )) and the output would be ```
Welcome @mudkip#0001! You are the 167th member to join the server!

smoky sinew
#

where are you calling variable_selects

raw quail
#

i changed the name variable_selects to callback and its working now

naive briar
#

Sounds about right

formal basin
#
@client.tree.command(name="anti-spam-on", description="blocks spamming from your server")
@app_commands.default_permissions(manage_guild=True)
async def antispam_on(interaction: discord.Interaction, mute_duration: int):
    ##with open('server-block.json','r',encoding='utf-8') as f:
        #key = json.load(f)
    #key[str(interaction.guild.id)]=str("on")
    #with open('server-block.json','w',encoding='utf-8') as f:
        #json.dump(key,f,indent=4,ensure_ascii=False)
    key = db.keys()
    if f'1 {interaction.guild.id}' in key:
        pass
        await interaction.response.send_message("Anti spam is already on")
    else:
        db[f"1 {str(interaction.guild.id)}"] =str(mute_duration)
  
        await interaction.response.send_message("Anti spam is on")
        channel2 = client.get_channel(1112053260879147130)
        await channel2.send(f"anti-spam-on command used by {interaction.user}")



@client.tree.command(name="anti-spam-off", description="Stops blocking spamming you have it on")
@app_commands.default_permissions(manage_guild=True)
async def antispam_off(interaction: discord.Interaction):
    #with open('server-block.json','r') as f:
        #key = json.load(f)
    db[f"1 {str(interaction.guild.id)}"]
    key = db.keys()
    if f'1 {interaction.guild.id}' not in key:
        pass

    else:
        #del key[f'{interaction.guild.id}']
        del db[f"1 {str(interaction.guild.id)}"]
        #key['off']='off'
    ##with open('server-block.json','w') as f:
        #json.dump(key,f,indent=2)
    await interaction.response.send_message("Anti spam is off")
    channel2 = client.get_channel(1112053260879147130)
    await channel2.send(f"anti-spam-off command used by {interaction.user}")
``` On the first command im storing the mute_duration in the db
#
author_id = message.author.id
    # Get current epoch time in milliseconds
   curr_time = datetime.datetime.now().timestamp() * 1000

    # Make empty list for author id, if it does not exist
   if not author_msg_times.get(author_id, False):
        author_msg_times[author_id] = []

    # Append the time of this message to the users list of message times
   author_msg_times[author_id].append(curr_time)

    # Find the beginning of our time window.
   expr_time = curr_time - time_window_milliseconds

    # Find message times which occurred before the start of our window
   expired_msgs = [
        msg_time for msg_time in author_msg_times[author_id]
        if msg_time < expr_time
    ]

    # Remove all the expired messages times from our list
   for msg_time in expired_msgs:
        author_msg_times[author_id].remove(msg_time)
    # ^ note: we probably need to use a mutex here. Multiple threads
    # might be trying to update this at the same time. Not sure though.

   if len(author_msg_times[author_id]) > max_msg_per_window: 
      key = db.keys()
      db[f"1 {str(message.guild.id)}"]
      if f'{message.guild.id}' not in key:
            pass
      duration = datetime.timedelta(minutes=db)
      embed = discord.Embed(title="User muted", description=f" {message.author.mention} has been muted", color=discord.Color.blue())
      embed.add_field(name = "Reason",value = "spamming")
      embed.add_field(name = "Mute duration",value = f"{duration} minutes")
      await message.author.timeout(duration)
      await message.channel.send(embed=embed)
``` how can i put it the duration
#

nvm

unkempt canyonBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

mellow pollen
#

I would like a role to be tagged as a required field when making a slash command. I tested a way earlier this week but can’t remember exactly my error but I know I was having some issues. I would like team:str to be a required ROLE from the sever

‘’’Python
@client.tree.command(name="snakes", description="Find the ladders and watch out for snakes!")
async def Game(interaction: discord.Interaction, team: str):
‘’’

slate swan
#

team: discord.Role

idle lantern
#

what is this ?

slate swan
#

A timer going down

idle lantern
#

how to use it?

slate swan
unkempt canyonBOT
#
Formatting code on discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

smoky sinew
slate swan
#

Down

#

Once it reaches 0 it still goes down in negative

#

Hence the "xx seconds ago"

#

Yes the number of seconds elapsed after 0 goes up, which is basically front-end only, though the timer itself continues going down

#

It doesn't do

3
2
1
0
1
2
3
swift acorn
north kiln
#

I changed my bot's name and suddenly discord says I am requesting intents I did not enable?

#

wth

north kiln
#

nvm I did something stupid lol

slate swan
#

how can i add !close to my ticket bot?

sour sand
#

ik its wierd but someone can come in my server and just test my bot for a few minutes, ask MP please

lean harbor
#
async def suggest(interaction: discord.Interaction, title: str, suggestion: str):
    suggestion_channel_id = 1106959842901504060

    suggestion_channel = bot.get_channel(suggestion_channel_id)
    if suggestion_channel is None:
        print(f"Could not find channel with ID {suggestion_channel_id}")
        return

    embed = discord.Embed(title=title, color=discord.Color.blurple())
    embed.add_field(name="User ID", value=str(interaction.user.id))
    embed.add_field(name="Suggestion", value=suggestion)

    suggestion_message = await suggestion_channel.send(embed=embed)

    await suggestion_message.add_reaction(':white_check_mark:')
    await suggestion_message.add_reaction(':x:')
    await interaction.response.send_message("Your suggestion has been submitted!")
#

Quick question, instead of the user Id, How would you make the username and tag of the person who used the command appear on the top with there pfp. Like carls suggestion command if you have seen it

still sentinel
#

Please don't joke about things like this. I'd suggest you delete that.

north kiln
#

user tag is gone soon anyway

slate swan
#

I Have a problem

#

i made a ticket bot, but there is no button to the text to open a ticket

#

no button

slate swan
# slate swan

the problem is what did you use pycord or discord_components?

#

the problem is, i used ctx to send the message, but then changed it to embed

#

it was working with the ctx

#

can i see the code

#

!paste

unkempt canyonBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

slate swan
#
@bot.command()
async def ticket(ctx):
  button = Button(label="Ανοίξτε ένα ticket.", style=discord.ButtonStyle.green)
  button.callback = ticketcallback
  view = View(timeout=None)
  view.add_item(button)
  embed2 = discord.Embed(title="TICKET", description="Ανοίξτε ένα ticket χρησιμοποιώντας το menu παρακάτω.")
  await ctx.send(embed=embed2)
#

ill show u only this part

slate swan
#

or just do liek this

#

the customer said embed

#

Ανοίξτε ένα ticket χρησιμοποιώντας το menu παρακάτω. like this.

#

wdym

slate swan
#

try

#

wait lemme show u the whole code

#

!paste

#

wait a sec

#

try

#

k

#

ohh

#

u forgot #

#

whar

#

what i forgot?

#

i think you made a lil mistake

#

or just

#

decode the lin of Choose an option below.

#

wym

#

idk why my python doesnt work

#

LOL

#

i tried but it didnt work.

#

better discord?

slate swan
#

what ab me?

dry kelp
slate swan
#

Not sure what to do i've enabled it

#

(well at least i think)

visual quest
#

What kind of metrics does @lusty spear tracks.

slate swan
#

@north kiln

#

Hey

#
        button = Button(label="Close", style=discord.Buttonstyle.red)

        async def button_callback(interaction, view):
          await channel.delete()
          await interaction.response.send_message("Ticket closed successfully.", ephemeral=True)

        button.callback = button_callback
      
        view = View()
        view.add_item(button)
        await channel.send(''' Καλήσπερα, ανοίξατε ένα donate ticket.. Παρακαλώ περιμένετε έναν ανώτερο. Όταν φτάσει, παρακαλώ ακολουθήστε προσεκτικά τις οδηγίες του.''')
#

Do you think this will work?

#

or should i use discord.ui

slate swan
tired pine
swift acorn
#

Does anyone know how they make the buttons un-clickable and also less visible like this after they timeout?
And can it be done in discord.py?

slate swan
#

!d discord.Button

unkempt canyonBOT
#

class discord.Button```
Represents a button from the Discord Bot UI Kit.

This inherits from [`Component`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Component "discord.Component").

Note

The user constructible and usable type to create a button is [`discord.ui.Button`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.Button "discord.ui.Button") not this one.

New in version 2.0.
slate swan
#

disabled attribute

primal pike
#

.d discord.bot

#

!d discord.Button

unkempt canyonBOT
#

class discord.Button```
Represents a button from the Discord Bot UI Kit.

This inherits from [`Component`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Component "discord.Component").

Note

The user constructible and usable type to create a button is [`discord.ui.Button`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.Button "discord.ui.Button") not this one.

New in version 2.0.
slate swan
#

Yes that's pretty much 1 to 1 what is 2 messages above

swift acorn
#

How would I make a input box in a modal that is optional?

smoky sinew
smoky sinew
swift acorn
swift acorn
smoky sinew
#

i don't think so, i think it's an empty string

swift acorn
#

i will just print it once and test it out

thorn horizon
#

Hello bit of a python noob and i stupidly started playing around with making a discord bot for fun, and I am trying to get what's probably a simple thing to work but i need some help please

name = input("what is your name? ")
print("hello " + name)

How do i Incorporate something like the above code into the bot command I have been using below so the bot will ask your name, and then reply hello plus the name that was input

@bot.command()
async def test (ctx):
await ctx.send(test complete)

If anyone can write it as a working line it would be amazing my brain has been fried trying to work this out today lol

potent spear
#

it's a method the client/bot object has

#

it can basically wait for a response from a user and take that input

#

OR you could use forms nowadays, if the question the person has to fill in is always the same and doesn't change based on previous answers

thorn horizon
#

Brilliant thank you will go look at how to do that

potent spear
#

a discord form would look like this:

swift acorn
#
@bot.tree.command(name="requestpromotion", description="Request a promotion to the next tier.")
async def requestpromotion(interaction : discord.Interaction):
    guild = bot.get_guild(1039553876778561536)
    check_if_cc = guild.get_member(interaction.user.id)
    if check_if_cc == None:
        await interaction.response.send_message("You cannot use this command.", ephemeral=True)
        return
    dm_channel = await interaction.user.create_dm()
    if not interaction.channel.id == dm_channel.id:
        await interaction.response.send_message("Please use this command in DMs!", ephemeral=True)
        return
    
    await interaction.response.send_modal(promotionrequestmodal())```

Getting this error from this command, not sure what it is 

Command 'requestpromotion' raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.components: Must be between 1 and 5 in length.
smoky sinew
swift acorn
#
class promotionrequestmodal(ui.Modal, title = "Request Tier Promotion"):
    channel_link = ui.TextInput(label="Channel to evalute", style=discord.TextStyle.short, placeholder="Your channel link", required=True, max_length=200)
    analytic_attachments = ui.TextInput(label="Channel analytics for past 2 months.", style=discord.TextStyle.long, placeholder="Analytics image links", required=True, max_length=200)
    additional_info = ui.TextInput(label="Additional Info", style=discord.TextStyle.long, placeholder="Any additional info you want to give", required=False, max_length=2000)

    channel_link = channel_link.value
    analytic_attachments = analytic_attachments.value
    additional_info = additional_info.value
    async def on_submit(self, interaction : discord.Interaction):
        embed = discord.Embed(
            color=discord.Colour.from_rgb(34, 255, 221),
            title="Promotion Request",
            description=f"""
[Channel To Evaluate]({self.channel_link})

**Additional Text**
{self.additional_info}"""
        )
        embed.set_author(name=f"{interaction.user} ({interaction.user.id})", icon_url=interaction.user.avatar)

        guild = bot.get_guild(1039553876778561536)
        channel = guild.get_channel(1110895460090118194)

        await channel.send(embed=embed)
        await channel.send(f"**Analytics (Past 2 Months):**\n{self.analytic_attachments}")
        await interaction.response.send_message("Thank you for submitting a request! It has been sent to our team and will be reviewed as soon as possible.")
smoky sinew
#
channel_link = channel_link.value
analytic_attachments = analytic_attachments.value
additional_info = additional_info.value

what is this

swift acorn
#

getting their value? or do the variables just contain that automatically

smoky sinew
#

yes but you do that in on_submit, not in the class

swift acorn
#

ah okay thank you

smoky sinew
#

remove that part of the code and use {self.channel_link.value} instead

swift acorn
#

gotcha tysm!!

#

I don't get errors sometimes man like how does that error explain that the issue is here

dry kelp
smoky sinew
#

avatar needs to be bytes, not URL

#

pretty sure i already said that to you...

dry kelp
#

to me?

#

Never a_sobs

smoky sinew
#

still if you looked at the docs you would see the correct way of using it

#

!d discord.TextChannel.create_webhook

unkempt canyonBOT
#

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

Creates a webhook for this channel.

You must have [`manage_webhooks`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_webhooks "discord.Permissions.manage_webhooks") to do this.

Changed in version 1.1: Added the `reason` keyword-only parameter.
dry kelp
#

Bro.. i have it open

#

i just remember using .url in order to get the bot avatar

smoky sinew
#

yeah that's an asset

dry kelp
#

i got hella shit open tbh

smoky sinew
#

oh right you're using disnake

dry kelp
#

Yeah

dry kelp
#

why does it create 3 times?

#

there's only 1 isistance running

smoky sinew
#

that part of the code is probably running multiple times then

dry kelp
#

it is not

swift acorn
#

Also I have this check for a wait_for function

dm_channel = await interaction.user.create_dm()
def check(message):
        if interaction.channel.id == dm_channel.id and message.author == interaction.user:
            return True
        else:
            return False

Butt it still returns True even if the message is sent by that user in a server channel which the bot is in too

smoky sinew
#

why are you even using create_dm

dry kelp
#

fixed

#

works x)

potent spear
swift acorn
smoky sinew
#

no

#

you can just do interaction.user.send

swift acorn
#

oh yeah true

swift acorn
potent spear
swift acorn
#

oh nvm yeah

#

so wait what is the difference?

potent spear
#

all I did was change

if poop == "nice":
 return True
else:
 return False```

to 
```py
return poop == "nice"```
see how much shorter that is for the exact same thing?
swift acorn
#

yeah but it doesn't change that it is not working bruh_coin

potent spear
swift acorn
#
channel_link = await bot.wait_for("message", check=check, timeout=240)
        channel_link = channel_link.content
potent spear
#

also "it doesn't work" should be something you don't want to say
let's say I say "my browser doesn't work"
what do you understand by that? indeed, almost nothing other than something is wrong

potent spear
swift acorn
potent spear
#

if message.channel.id == <user_dm_channel_id> and ...

#

that'll do 😉

swift acorn
smoky sinew
#

or just do ```py
isinstance(message.channel, discord.DMChannel) and message.channel.recipient == user

dry kelp
#

I've finished the entire antinuke setup a_sobs

#

was a pain...

#

@smoky sinew Could i dm you ?

smoky sinew
#

my dms are closed

#

as it says in my about me

dry kelp
smoky sinew
dry kelp
#

Yeah but if we become friends, they won't be closed anymore wtf

smoky sinew
#

or you can ask literally anywhere else like here or my discord server

dry kelp
#

I am looking rn thru disnake docs

#

and i don't see the permissions to manage sounboards

#

like there's nothing in the docs

smoky sinew
#

i don't think disnake has that feature yet, when it does it will probably be called Permission.manage_expressions

dry kelp
#

@smoky sinew Asked them and they have a version 2.9

#

what was the command to update?

potent spear
#

but uhm, python -m pip install --upgrade <package_name> it is

snow coral
#

how can i make it so only a certain user use a command

smoky sinew
#

!d discord.ext.commands.check

unkempt canyonBOT
#

@discord.ext.commands.check(predicate)```
A decorator that adds a check to the [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or its subclasses. These checks could be accessed via [`Command.checks`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command.checks "discord.ext.commands.Command.checks").

These checks should be predicates that take in a single parameter taking a [`Context`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context"). If the check returns a `False`-like value then during invocation a [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure") exception is raised and sent to the [`on_command_error()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") event.

If an exception should be thrown in the predicate then it should be a subclass of [`CommandError`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError"). Any exception not subclassed from it will be propagated while those subclassed will be sent to [`on_command_error()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error").
dry kelp
#

How can i send a message using a webhook url?

snow coral
dry kelp
snow coral
#

ohhh

#

@ mudkip#0001 is like the smartest one here so u could probably ask him

#

lol

vocal snow
unkempt canyonBOT
#

classmethod from_url(url, *, session=..., client=..., bot_token=None)```
Creates a partial [`Webhook`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Webhook "discord.Webhook") from a webhook URL.

Changed in version 2.0: This function will now raise [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.11)") instead of `InvalidArgument`.
vocal snow
#

make a Webhook object with this, then use webhook.send

dry sedge
#

How can I join a discord group dm call with python

smoky sinew
dry sedge
#

Is it possible with any coding language

#

because ive been looking for this for years

sick birch
smoky sinew
#

it is possible, but would be against discord's terms of service

dry sedge
smoky sinew
#

does not matter it would still be against TOS

trim barn
#

or does PyCord run the show now

rugged shadow
smoky sinew
dry kelp
#

Is it possible to display how long ago in embed footer?

smoky sinew
#

no

trim barn
#

Should I use nextcord, pycord, or discord.py for future projects?

smoky sinew
trim barn
#

so not sure about what came afterI

#

I want to do a Python project or maybe something in JavaScript now that I'm majoring in CS

#

Java is not a suitable language for discord bot creation so idk

smoky sinew
#

you are probably going to find more people who can help you with discord.py but it still doesn't mean it's better

smoky sinew
trim barn
smoky sinew
#

you're probably referring to javascript though i just realized i didn't read your message

trim barn
#

plus I am more comfortable with Python

#

Java... the OOP lang

trim barn
smoky sinew
#

i use java a lot for projects that wouldn't work well in python

#

i would recommend scrolling through discord.py disnake or nextcord docs to see which one seems easier for you

vale wing
#

The timestamp arg in the constructor

dry kelp
#

there's none

vale wing
#

That's called a method not a constructor

#
embed = discord.Embed(timestamp=datetime_obj)```
#

!d discord.Embed

unkempt canyonBOT
#

class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

x == y Checks if two embeds are equal.

New in version 2.0...
smoky sinew
raw quail
#

Outputting one of the functions in fred_data.py via the first select option results in an interaction failed error in discord. however, if i make and execute a command like the second picture, it works normally. what could be the problem?

#

If i use the select option function, does the interaction failed error occur because the function doesn't wait for the time to receive and visualize the data while the function is operating?

storm skiff
#

Repeating code 🤢

vale wing
#

Indeed

#

send_message is the same in every condition yet not brought out

#

And that if chain can be done with dict

raw quail
#

hmm..

#

solved. i modified to add interaction.defer() and interaction.fllowup.send instead of interaction.send_message

slate swan
#

how to make my bot send messages like this

smoky sinew
slate swan
#
discord.InteractionResponse.send_message("test")
smoky sinew
#

that doesn't mean you have to include discord.InteractionResponse in your code

#

you have to get an InteractionResponse object by using interaction.response and also awaiting it

slate swan
#

k i did it

#

worked

#

another problem

#

every time i run !clear

#

i have this error

#
Traceback (most recent call last):
  File "/home/runner/Atomic/venv/lib/python3.10/site-packages/discord/ext/commands/core.py", line 229, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 314, in clear
    await ctx.send(f'Έσβησα ', {amount}, ' Μηνύματα.')
TypeError: Context.send() takes from 1 to 2 positional arguments but 4 were given

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/Atomic/venv/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 1350, in invoke
    await ctx.command.invoke(ctx)
  File "/home/runner/Atomic/venv/lib/python3.10/site-packages/discord/ext/commands/core.py", line 1023, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "/home/runner/Atomic/venv/lib/python3.10/site-packages/discord/ext/commands/core.py", line 238, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Context.send() takes from 1 to 2 positional arguments but 4 were given
#
@bot.command()
async def clear(ctx, amount=10):
  await ctx.channel.purge(limit=amount+1)
  await ctx.send(f'Έσβησα ', {amount}, ' Μηνύματα.')
  await asyncio.sleep(2)
  await ctx.channel.purge(limit=amount)
#

!f-string

unkempt canyonBOT
#
Format-strings

Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.

>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."

Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.

slate swan
#

also, it ignores this line ```py
await ctx.send(f'Έσβησα ', {amount}, ' Μηνύματα.')

#

fix your f-string signature

#

done

slate swan
#

fixed

#

then show fixed code

#
  await ctx.send(f"Έσβησα ', {amount}, ' Μηνύματα.")
#

that is not how you create f-strings

#

bruh

slate swan
#

i forgot

#

its my old code, its there since i started python

#

!e f"Έσβησα ', {amount}, ' Μηνύματα."

unkempt canyonBOT
#

@slate swan :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     f"Έσβησα ', {amount}, ' Μηνύματα."
004 |                  ^^^^^^
005 | NameError: name 'amount' is not defined
slate swan
#

hm

#
  await ctx.send(f"Έσβησα {amount} Μηνύματα.")
#

!e amount = 1; f"Έσβησα ', {amount}, ' Μηνύματα."

unkempt canyonBOT
#

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

[No output]
slate swan
#

do you get error now?

#

lemme see

#

Nope, it works

#

ty

#

1 last question

smoky sinew
slate swan
#

how to add more selections

slate swan
smoky sinew
slate swan
#

!paste

#

(ignore the button, its in another message)

slate swan
#

like you did before

#

add like a 3rd?

#

select = Select(options=[
discord.SelectOption(label="Support Ticket", value="01", emoji="📄", description="Open a support ticket."),
discord.SelectOption(label="Donate ticket", value="02", emoji="💸", description="Open a Donate ticket.")
])

there you create select

#

add another option

smoky sinew
#

why does everyone like instantiating View directly instead of subclassing it

slate swan
#

cuz better

smoky sinew
#

your code is basically unreadable

smoky sinew
#

you can't easily see where this separates

#

whereas you could split it up into different functions

slate swan
# slate swan no idea
  select = Select(options=[
  discord.SelectOption(label="Support Ticket", value="01", emoji="📄", description="Open a support ticket."),
  discord.SelectOption(label="Donate ticket", value="02", emoji="💸", description="Open a Donate ticket."),
  discord.SelectOption(label="SR ticket", value="02", emoji="⭐", description="Become SR.")
#

wait

#

i forgot 03

#
  select = Select(options=[
  discord.SelectOption(label="Support Ticket", value="01", emoji="📄", description="Open a support ticket."),
  discord.SelectOption(label="Donate ticket", value="02", emoji="💸", description="Open a Donate ticket."),
  discord.SelectOption(label="SR ticket", value="03", emoji="⭐", description="Become SR.")
])
#

add like elif select.values[0] == "02":

#

@slate swan

#

show me the error

#

theres no error, but it shows this

#

if there is no error then whats the problem

#

no problem

#

the problem is my question

north kiln
slate swan
smoky sinew
#

yellow ☎️

slate swan
#
    if select.values[0] == "03":
                                ^
IndentationError: unindent does not match any outer indentation level```
#

help me

smoky sinew
#

why do you keep putting y in your messages 😭

slate swan
#

why does replit keep giving me errors 😭

smoky sinew
#

fix your indentation

slate swan
#

!paste

upbeat otter
smoky sinew
#

it's literally 5 messages abovwe

#

also like

#

@slate swan

upbeat otter
#

im blind

slate swan
smoky sinew
#

look at the line

slate swan
#

ohh

#

lemme fix it

#

!paste

unkempt canyonBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

slate swan
#

Fixed?

smoky sinew
slate swan
#

welp

#

i did it, fixed

smoky sinew
#

also why did you replace all elifs with ifs

slate swan
#

i didnt

smoky sinew
#

but you did

slate swan
#

only that one

smoky sinew
#

why

slate swan
#

or not

slate swan
#

ty btw

#

@smoky sinew

#

can i ask u smth

smoky sinew
slate swan
#

can i ask u 3 questions

#

i already asked 2

smoky sinew
#

sure

slate swan
#

Okay so

#

Im making a bot for a customer, and he told me to: When a user joins a specific vc, he wants to move him in another one

#

how to do that?

smoky sinew
#

voice rooms or just the moving part?

slate swan
#

let me show u

#

Lol

smoky sinew
#

!d discord.on_voice_state_update

unkempt canyonBOT
#

discord.on_voice_state_update(member, before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") changes their [`VoiceState`](https://discordpy.readthedocs.io/en/latest/api.html#discord.VoiceState "discord.VoiceState").

The following, but not limited to, examples illustrate when this event is called...
slate swan
#

He wants this

smoky sinew
#

well that's not just moving to a new channel

#

you have to create and delete it too

#

but just use the on_voice_state_update event

slate swan
#

yeah

#

i wish i knew how

smoky sinew
#

have you never used an event listener before?

slate swan
#

the only events i used

#

is

smoky sinew
#

it doesn't matter which events you use they all work the same

slate swan
#
@bot.event
async def on_member_join(member):
  role = discord.utils.get(member.guild.roles, name = "Civilian")
  await member.add_roles(role)
  channel = bot.get_channel(1091042545133437015)
#

still

#

idk

upbeat otter
#

!d discord.Guild.create_text_channel

unkempt canyonBOT
#
await create_text_channel(name, *, reason=None, category=None, news=False, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=..., ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel "discord.TextChannel") for the guild.

Note that you must have [`manage_channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") to create the channel.

The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.11)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/latest/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.

Note

Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
slate swan
#

thats not Asher thats Ash

upbeat otter
#

yes

#

we are totally different

formal basin
#
     global author_msg_counts

     author_id = message.author.id
    # Get current epoch time in milliseconds
     curr_time = datetime.datetime.now().timestamp() * 1000

    # Make empty list for author id, if it does not exist
     if not author_msg_times.get(author_id, False):
        author_msg_times[author_id] = []

    # Append the time of this message to the users list of message times
     author_msg_times[author_id].append(curr_time)

    # Find the beginning of our time window.
     expr_time = curr_time - time_window_milliseconds

    # Find message times which occurred before the start of our window
     expired_msgs = [
        msg_time for msg_time in author_msg_times[author_id]
        if msg_time < expr_time
    ]

    # Remove all the expired messages times from our list
     for msg_time in expired_msgs:
        author_msg_times[author_id].remove(msg_time)
    # ^ note: we probably need to use a mutex here. Multiple threads
    # might be trying to update this at the same time. Not sure though.

     if len(author_msg_times[author_id]) > max_msg_per_window:
      key = db.keys()
      db[f"1 {str(message.guild.id)}"]
      if f'1 {message.guild.id}' not in key:
            pass
      else:
          duration = datetime.timedelta(minutes=10)
          embed = discord.Embed(title="User muted", description=f"{message.author.mention} has been muted", color=discord.Color.blue())
          embed.add_field(name = "Reason",value = "spamming")
          embed.add_field(name = "Mute duration",value = "10 minutes")
          await message.author.timeout(duration)
          await message.channel.send(embed=embed)
``` can someone help me im making an anti spam system but its not working the guild id is in the db
#

i think discord is having problems

storm skiff
formal basin
formal basin
#

this was working until i switched the code a bit

#

and then put it back to normal

storm skiff
#

I doubt await message.author.timeout(duration) ever worked

#

Since you need the member object

#

But a lot of your code is undefined, hard to know what's wrong

slate swan
#

Add a few print statements inbetween your code to narrow down the cause.

wanton quiver
#

can ayone say how to make an embed colour bar less in discord py

storm skiff
wanton quiver
#

there is a setting which we can do

storm skiff
#

Then use that one haha

#

I don't know one

#

If you do color=None it will still use a color

slate swan
unkempt canyonBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

plain pollen
#

@wanton quiver are you sure that person isn't just using the same color code as the embed? try switching to light theme and checking

naive briar
formal basin
naive briar
#

I don't think I'm that blind

slate swan
#

It's in his on_message event, around line 300. It's best to only send the code that's failing though @formal basin. Along with other relevant stuff.

#

I think Discord servers are slow today Pain

naive briar
#

Alright then

formal basin
#
@client.event
async def on_message(message):
  if message.author.id == client.user.id:
        return 
  await client.process_commands(message)
  discord_server = ["discord.gg"]
  if message.author.guild_permissions.ban_members:
    pass
  
  else:
   if any (word in message.content.lower() for word in discord_server):
     key = db.keys()
     db[str(message.guild.id)]
     if f'{message.guild.id}' not in key:
            pass
     else:
          await message.delete()
          await message.channel.send(f"{message.author.mention} you can not send discord servers here")

     

     

     author_id = message.author.id
    
     curr_time = datetime.datetime.now().timestamp() * 1000

   
     if not author_msg_times.get(author_id, False):
        author_msg_times[author_id] = []

   
     author_msg_times[author_id].append(curr_time)

 
     expr_time = curr_time - time_window_milliseconds

   
     expired_msgs = [
        msg_time for msg_time in author_msg_times[author_id]
        if msg_time < expr_time
    ]

     for msg_time in expired_msgs:
        author_msg_times[author_id].remove(msg_time)
   

     if len(author_msg_times[author_id]) > max_msg_per_window:
      key = db.keys()
      db[f"1 {str(message.guild.id)}"]
      if f'1 {message.guild.id}' not in key:
            pass
            print("no server id in db")
      else:
          print("server id in db")
          duration = datetime.timedelta(minutes=10)
          embed = discord.Embed(title="User muted", description=f"{message.author.mention} has been muted", color=discord.Color.blue())
          embed.add_field(name = "Reason",value = "spamming")
          embed.add_field(name = "Mute duration",value = "10 minutes")
          await message.author.timeout(duration)
          await message.channel.send(embed=embed)```
formal basin
#
     @client.event
async def on_message(message):
  if message.author.id == client.user.id:
        return 
  await client.process_commands(message)
  discord_server = ["discord.gg"]
  if message.author.guild_permissions.ban_members:
    pass
  
  else:
   if any (word in message.content.lower() for word in discord_server):
     key = db.keys()
     db[str(message.guild.id)]
     if f'{message.guild.id}' not in key:
            pass
     else:
          await message.delete()
          await message.channel.send(f"{message.author.mention} you can not send discord servers here")

     

     

     author_id = message.author.id
    
     curr_time = datetime.datetime.now().timestamp() * 1000

   
     if not author_msg_times.get(author_id, False):
        author_msg_times[author_id] = []

   
     author_msg_times[author_id].append(curr_time)

 
     expr_time = curr_time - time_window_milliseconds

   
     expired_msgs = [
        msg_time for msg_time in author_msg_times[author_id]
        if msg_time < expr_time
    ]

     for msg_time in expired_msgs:
        author_msg_times[author_id].remove(msg_time)
   

     if len(author_msg_times[author_id]) > max_msg_per_window:
      key = db.keys()
      db[f"1 {str(message.guild.id)}"]
      if f'1 {message.guild.id}' not in key:
            pass
            print("no server id in db")
      else:
          print("server id in db")
          duration = datetime.timedelta(minutes=10)
          embed = discord.Embed(title="User muted", description=f"{message.author.mention} has been muted", color=discord.Color.blue())
          embed.add_field(name = "Reason",value = "spamming")
          embed.add_field(name = "Mute duration",value = "10 minutes")
          await message.author.timeout(duration)
          await message.channel.send(embed=embed)```
formal basin
slate swan
#

Anyway I can't tell you what's going wrong so we're either both missing something obvious or there's an issue outside your code (DB issue perhaps).
Best bet is to probably do as I said earlier, add a print statement after any line of code that may be error-prone, or after any conditional statements. Check they're actually running as expected, and check variables against their expected values.

naive briar
#

Stop replying with the same message

storm skiff
formal basin
#

wait wth

naive briar
#

You know what, I give up

formal basin
#

why is it replying so many times

formal basin
#

i only did once

naive briar
#

Use that excuse on someone else

plain pollen
formal basin
#

discord is going mad it is taking so long to send

smoky sinew
unkempt canyonBOT
#
I don't think so.

No documentation found for the requested symbol.

smoky sinew
formal basin
#

take so long

slate swan
#

I'm having issues but it's not sending my messages twice or anything, though I heard somewhere it was an issue with the mobile client

formal basin
#

im not on moblie

plain pollen
smoky sinew
#

yeah it's with the app

naive briar
formal basin
#

maybe this the reason why my anti spam aint working

formal basin
naive briar
#

Good job

formal basin
plain pollen
naive briar
#

Use that excuse on someone else

formal basin
#

what the heck

#

maybe this the reason why my anti spam aint working

#

what the heck is happening

smoky sinew
#

lmaoo

naive briar
#

amoled mode

formal basin
naive briar
smoky sinew
#

ahahahahaha this is so funny

formal basin
#

my bot just broke

naive briar
#

Great

#

amoled mode

formal basin
#

my bot just broke

formal basin
formal basin
#

yeah i just tried to test my anti spam

#

not a good idea in this situation

#

my bot just broke

#

yeah i just tried to test my anti spam

#

not a good idea in this situation

naive briar
formal basin
#

not a good idea in this situation

slate swan
naive briar
lean harbor
#

Can discord bots delete channel

tawdry gazelle
#

discord is back?

storm skiff
smoky sinew
unkempt canyonBOT
#
No way, José.

No documentation found for the requested symbol.

lean harbor
storm skiff
smoky sinew
lean harbor
smoky sinew
lean harbor
#

but still a big loss.

smoky sinew
#

what does that have to do with what i just said

lean harbor
storm skiff
#

You sending screenshots with 60% of your token visible for no reason says enough

smoky sinew
#

you basically re-leaked it

slate swan
#

Ouch

lean harbor
storm skiff
#

But it just shows your awareness of security

lean harbor
#

it

storm skiff
#

Ah first no one will see it, now it's the old token 👍

smoky sinew
storm skiff
#

What was the point of the screenshot anyway?

sour sand
#

hi, struggling on something

#

on a reboot, the ticket configuration dosent save in the settings.db, any help would be great.

north kiln
#

why you reconnect after creating all the transactions

#

also there isn't something called REPLACE INTO

sour sand
#

can you explain a little bit better ?

slate swan
#

Guys i need help.

#

i made a bot and they somehow hacked it and did this

#

the code is not changed

#

how did this happen?

#

@smoky sinew

smoky sinew
#

huh

#

what happened

slate swan
#

they hacked the bot somehow

#

and did this to the server

smoky sinew
#

your token probably got leaked

#

or someone else has access to your bot ig rd_shrug

radiant bough
#

What do you need help with tho yert

slate swan
#

how?

smoky sinew
slate swan
#

what is a vps

smoky sinew
#

what are you using to host your bot

slate swan
#

replit keep_alive with uptime robot

north kiln
radiant bough
#

joe_salute makes sense ngl

north kiln
#

can you actually get your token stolen through replit

radiant bough
#

someone viewed your repl and got your token?

slate swan
#

but how did they see my repl

upbeat otter
smoky sinew
#

because replit makes all your code public by default i guess lmao

naive briar
upbeat otter
#

,

naive briar
#

But they support environment variables, so you should use that instead

radiant bough
slate swan
#
token = os.environ.get("TOKEN")
bot.run(TOKEN)
#

This works?

upbeat otter
#

yes

slate swan
#

is there any way to make anti-nuke system?

#

Yep there is

smoky sinew
#

that's all it takes

slate swan
#

my token is only on replit

#

But my code using raw token is public gigachad

#

Pretty much the same as giving it to anyone

#

Also replit is not made for Discord bots

slate swan
#

And as I said, it's not made for that

storm skiff
smoky sinew
storm skiff
#

I oversaw that basic logic

north kiln
#

I haven't hosted on a vps yet but I got confused for all the product names on those cloud platforms

upbeat otter
warm vigil
#

salve rapaziada

north kiln
#

Don't know which one I should choose if it doesn't straight up say vps tbh

warm vigil
#

tudo baum com vcs?

storm skiff
#

I like ubuntu

upbeat otter
warm vigil
#

hosting

upbeat otter
#

I wasn't talking about hosting

storm skiff
#

Yeah but why not develop it locally

warm vigil
#

nao entendi

upbeat otter
#

replit is a good choice imo

smoky sinew
#

which cloud service are you using @north kiln

storm skiff
#

I wonder what % that applies to

upbeat otter
#

online editors*

smoky sinew
#

i'll tell you what they call it

north kiln
#

I haven't chosen one lmao

#

Just looking for prices

warm vigil
#

concordo

upbeat otter
storm skiff
#

My pc is dog but can easily develop bots locally

upbeat otter
#

pc cannot be a dog

#

pc is pc.

storm skiff
#

So I can't imagine it being a general advice you should give

warm vigil
#

pichau é a melhor loja de pc

smoky sinew
north kiln
#

Please speak English

warm vigil
#

pycharm é melhor

north kiln
#

@warm vigil

warm vigil
warm vigil
upbeat otter
#

why does everybody come to use replit in the first place

#

and that too just for discord bots

smoky sinew
#

only to host it

#

more importantly people don't have money to run a bot forever

upbeat otter
#

what's the point of running a bot forever

#

💀

#

nvm im tripping

warm vigil
#

interactions is best lib for discord bot

slate swan
smoky sinew
slate swan
warm vigil
#

does anyone have any discord bot projects available on github?

smoky sinew
#

yes!

warm vigil
#

Can you send me the repository link?

smoky sinew
slate swan
#

That's not leaf

#

🗿

rapid herald
#

Lol

smoky sinew
slate swan
smoky sinew
#

i think

slate swan
#

ok

harsh marsh
#

Hi I did a command to remove the role from a user but I added a condition if user does not have the role print failed to remove the role but even if I have the role I can’t remove it from myself.
See the screenshot for the code
Thanks for help ^^

sick birch
# harsh marsh

role is a discord.Role object, but name= kwarg is a str

#

So it'll always be None

#

You just need to do

if role in member.roles:
  # user has role
else:
  # user doesn't have role
sick birch
# harsh marsh

In your else statement you also don't need to use utils.get, you already have role

#

And you don't need to repeat the .remove_roles twice

#

await member.remove_roles(role, reason=reason)

harsh marsh
#

yes i corrected that

#

thanks for your help man

slate swan
#

how to make like when a user interacts with a button, the bot changes their roles?

#
await member.add_role("role")```?
formal basin
slate swan
#

u are wrong

formal basin
#

im pretty sure you need it in a class

slate swan
#

im just asking, i wont add it in a code

formal basin
#

oh

potent spear
reef charm
#

Hey so i currently have discord bot written in python and its hosted on a server via VSC. I execute the code and it runs perfectly fine but sometimes my server restarts or something changed and the bot isnt running anymore

Is there a way to see that your code is running fine 24/7 and otherwise u get some sort of notification? or do i need to build that into my code itself

twilit grotto
karmic mulch
#

Alternatively you can build and add your own HTTP service. For that I can recommend aiohttp, which has a simple to setup http server that can run in the same event loop as your bot.

fervent pebble
#

Hello guys

#

is there a way i can create like a bot that loads messages from my whatsapp and then sends it too my discord

#

note: Whatsapp wont have to be on my phone or laptop

tired pine
#

No because you can't access someone's whatsapp messages from an external device

smoky sinew
#

can setting allowed_mentions in send override the one passed to discord.Client?

potent spear
smoky sinew
#

👍

smoky sinew
wanton quiver
#

Hey can we make graphs like this using python libraries , if i have weather forecasting data

unkempt canyonBOT
golden portal
#

you could do that effect with purely just matplotlib

upbeat otter
#

You could post the question in a relevant channel too 💀

fresh hatch
upbeat otter
#

one actually should

fresh hatch
upbeat otter
#

....?

slate swan
#

Bro joined yesterday 🗿

drifting arrow
#

How to load ascii using json?
Whenever I try it turns from my json file into •

drifting arrow
#

It's fine. I eventually found the right answer on stackoverflow

slate swan
#

Your question is regarding basic Python and JSON, even if you use it in a bot it's not a bot development question.

drifting arrow
#

It's fine tho. I found my answers online.

slate swan
#

Not a reason to use a channel that isn't related to your question ThumbsUp

drifting arrow
#

It's only an issue if someone else was utilizing this channel for its intended use.

slate swan
#

No. Here again, a channel being inactive doesn't change the rules for said channel and makes it useable for any random questions just because you believe so.

fresh hatch
#

Please take discussions about this server to a relevant channel guys

slate swan
#

Thank you, parrot 🦜

smoky sinew
#

but your issue is probably with encoding

smoky sinew
slate swan
#

Look 1 message below or 2 above the message you've replied to

#

They already got their answer and, hopefully, understand channels have topics - no point on getting over it again I guess

slate swan
#
Traceback (most recent call last):
  File "/home/runner/Atomic/venv/lib/python3.10/site-packages/discord/ui/view.py", line 427, in _scheduled_task
    await item.callback(interaction)
  File "main.py", line 124, in my_callback
    channel = await guild.create_text_channel(f"{interaction.user.name}-support-ticket", category=category, overwrites=overwrites)
  File "/home/runner/Atomic/venv/lib/python3.10/site-packages/discord/guild.py", line 1309, in create_text_channel
    data = await self._create_channel(
  File "/home/runner/Atomic/venv/lib/python3.10/site-packages/discord/guild.py", line 1175, in _create_channel
    payload = {'allow': allow.value, 'deny': deny.value, 'id': target.id}
AttributeError: 'NoneType' object has no attribute 'id'
#

Whats this error

primal orchid
#

print("Happy Pride Month")

slate swan
#

Means target is None

#

How did this happen, it was working yesterday and i didnt change the code

#

You tell us, you have the code

#

Get your category by ID, not by name

#

The issue is likely that role is None

#

Lemme double check the role

#

Yeap

#

Should get channels etc. by IDs though

#

nah it happened bc they nuked the server and the name of the role and the id changed

#

How to make like

#

if a user interacts with a button

#

the bot dms him

#

Add a callback to the button and send a message in that callback

#
await interaction.response.send_message
```?
#

Or

#

Well there you'll send in the channel, so no

#

Just like you'd usually send a DM

upbeat otter
#

!d discord.User.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/latest/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.11)") of [`File`](https://discordpy.readthedocs.io/en/latest/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/latest/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.11)") of [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
upbeat otter
#

interaction.user.send()

slate swan
#

Though you'll need to send some interaction response

#

Unless you don't really care about the interaction failed error showing up for the user

slate swan
#
main.py:132: RuntimeWarning: coroutine 'Messageable.send' was never awaited
  interaction.user.send(embed=embed)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
#

wait

#

im fr so dumb i didnt await

vocal snow
#

yeah thats exactly what the first line of the error says lol

slate swan
#

Alright i got a question

#

imagine i have the command !clear

#

how can i make it so people with a specific role can run this command

#

?

vocal snow
#

!d discord.ext.commands.has_role

unkempt canyonBOT
#

@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has the role specified via the name or ID specified.

If a string is specified, you must give the exact name of the role, including caps and spelling.

If an integer is specified, you must give the exact snowflake ID of the role.

If the message is invoked in a private message context then the check will return `False`.

This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")...
slate swan
#
@bot.command()
@discord.ext.commands.has_role("Staff")
async def clear(ctx):
#

lke that?

#

Try it and see

#

i made a welcome system but it has this error