#discord-bots

1 messages · Page 17 of 1

slate swan
shrewd apex
#

how are these panels glowing 💀

slate swan
#

lol

zealous jay
#

idk some weird screenshot app

silk fulcrum
#

magik

silk fulcrum
shrewd apex
#

what's with this weird deco

slate swan
#
  @app_commands.command(name="post", description="post a gamepass")
  @app_commands.checks.cooldown(1, 600, key=lambda i: (i.user.id))
  async def post(self, interaction: discord.Interaction, gamepassid: str):
        #view = discord.ui.View() # Establish an instance of the discord.ui.View class
        #style = discord.ButtonStyle.blurple  # The button will be gray in color
        #gamepass = discord.ui.Button(style=style, label="GAMEPASS", url=gamepass)
        #view.add_item(item=gamepass)
          gamepass=requests.get(f"https://api.roblox.com/marketplace/game-pass-product-info?gamePassId={gamepassid}").json()
          thumb=requests.get(f"https://thumbnails.roblox.com/v1/users/avatar-bust?userIds={gamepass['Creator']['Id']}&size=75x75&format=Png&isCircular=false").json()['data'][0]['imageUrl']
          if not thumb == "none":
            embed=discord.Embed(description="your gamepass has `successfully` been posted in | [#1004310613146734682](/guild/267624335836053506/channel/1004310613146734682/)",color=color.color)
            await interaction.response.send_message(embed=embed)
            channel = self.client.get_channel(1004310613146734682)
            embed=discord.Embed(title=f"new post from {interaction.user}", description=f"donate bobux to **{gamepass['Creator']['Name']}**\n `Robux` = {gamepass['PriceInRobux']}\n`gamepass` = **https://www.roblox.com/game-pass/{gamepassid}/{gamepass['Name']}**",color=color.color)
            embed.set_thumbnail(url=thumb)
            embed.set_footer(text="/post to post your gamepass!")
            await channel.send(embed=embed)
silk fulcrum
#

hm it's post

slate swan
#

i fixxed

shrewd apex
#

requests is sync

silk fulcrum
#

omg, my eyes 💀

slate swan
#

it was my god damn indent i didnt see

#

LOL

shrewd apex
#

hmm well i mean it's better than what i am seeing on phone atleast

silk fulcrum
#

i had friends those didn't type spaces anywhere they could, same here, do you guys like hate them?

shrewd apex
silk fulcrum
#

i also have friends those can't write code

shrewd apex
#

err by that i mean none of my friends do

silk fulcrum
#

oo good

shrewd apex
#

not a single one 😔

silk fulcrum
#

or not

shrewd apex
#

and i knew atleast 180 people in same class as me in past years

silk fulcrum
#

well those were not really friends, those are my classmates at programming school, everyone else I know except my dad can't code

shrewd apex
#

nearest we got was when they played pubg in school pc in cs class 😔

silk fulcrum
#

lol

shrewd apex
#

wut u go to programming school?👀

silk fulcrum
zealous jay
#

In my school we just used scratch and after a few classes the teacher disappeared

silk fulcrum
#

and it was trash

shrewd apex
#

how many years/months

silk fulcrum
#

and I left

silk fulcrum
zealous jay
#

yeah it sucked lol

#

i guess it was good for understanding the basics

shrewd apex
#

might as well do turtle in python

#

bruh what's basics in that?🗿

vocal snow
#

Turtle is useful

silk fulcrum
zealous jay
#

loops, functions

shrewd apex
#

err well each to their own

zealous jay
#

variables

silk fulcrum
zealous jay
#

yeah

#

I hope I never get anywhere near to scratch again tho

silk fulcrum
#

lmao

zealous jay
#

Boring af

silk fulcrum
slate swan
#

As you can see this embed has 6 values. The values that this embed can send can be random. But I want this embed to send only 30 specific amount of values, like 10. And then make embed pages

#

How can I do this?

zealous jay
#

I think there's a module called pagify for that

#

Idk tho I've never used pages

vocal snow
slate swan
vocal snow
#

And you're using dpy 2.0 right

slate swan
#

Not yet but i'll upgrade

#

Im using 1.7

vocal snow
#

There are examples of views here

storm rose
#
@client.command()
async def kick(ctx, member: discord.Member, *, reason=None):
    await member.kick(reason=reason)
    #await ctx.send(f'Kicked {member.mention}')

@client.command()
async def ban(ctx, member: discord.Member, *, reason=None):
    await member.ban(reason=reason)
    #await ctx.send(f'Banned {member.mention}')

Traceback (most recent call last):
File "/Users/kevin/Desktop/Projects/Python/Bot/main.py", line 43, in <module>
@client.command()
AttributeError: 'Client' object has no attribute 'command'

#

Whats wrong?

silk fulcrum
#

only Bot classes have command attr

#

you have client = discord.Client

#

however it should be client = commands.Bot to use commands

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a Discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.

Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client"), this class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree "discord.app_commands.CommandTree") and is automatically set upon instantiating the class.

async with x Asynchronously initialises the bot and automatically cleans up.

New in version 2.0.
cinder swift
#

Is that possible to make a argument missing message with integer missing?
I've tried doing but it returns that an integer argument cannot be NoneType

storm rose
#

So should I replace client = discord.Client with client = commands.Bot

pearl shoal
#

can anyon help me'

silk fulcrum
unkempt canyonBOT
#

@silk fulcrum :white_check_mark: Your 3.11 eval job has completed with return code 0.

Integer something is missing.
pearl shoal
#

anyone here

pearl shoal
#

this isnt working

silk fulcrum
pearl shoal
#

ok

silk fulcrum
pearl shoal
#

no

silk fulcrum
#

can you show full code of a command/event?

pearl shoal
#

okk

#

import discord

TOKEN = 'bottoken'
client = discord.Client()

@client.event
async def on_ready():
print(f'{client.user} Is ON')

@client.event
async def message_on(message):
username = str(message.author).split('#')[0]
username = str(client.user).split('#')[0]
user_message = message.content
channel = message.channel.name
print(f'{username}: {user_message} ({channel})')
if message.author == client.user:
return

if message.channel.name == 'spam':
    if user_message.lower() == 'Hi':
        await message.channel.send(f'hello')
        return

client.run(TOKEN)

#

it was working fine yesterday

unkempt canyonBOT
#

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.

storm rose
silk fulcrum
storm rose
#
import discord
from discord.ext import commands
import os

os.system('cls' if os.name == 'nt' else 'clear')

token = ''

client = commands.Bot(command_prefix='!')

@client.event
async def on_ready():
    print('------')
    print('Logged in as')
    print("Bot name: ",client.user.name)
    print("Bot ID: ",client.user.id)
    print('------')

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content == 'hello':
        await message.channel.send('Welcome to the server!')

    if message.content == 'cool':
        await message.add_reaction('\U0001F60E')

    if message.content == '?help':
        await message.channel.send('Here are the commands: \n\n ?help \n ?cool \n ?hello \n ?ping \n ?info \n ?invite \n ?source')


@client.event
async def on_message_edit(before, after):
        await before.channel.send(
            f'{before.author.mention} edited their message!'
            f'\n**Before**: {before.content}'
            f'\n**After**: {after.content}'
            
            )


@client.command()
async def kick(ctx, member: discord.Member, *, reason=None):
    await member.kick(reason=reason)
    #await ctx.send(f'Kicked {member.mention}')

@client.command()
async def ban(ctx, member: discord.Member, *, reason=None):
    await member.ban(reason=reason)
    #await ctx.send(f'Banned {member.mention}')

client.run(token)

silk fulcrum
storm rose
#

I removed the token for this message onöy

#

only*

pearl shoal
silk fulcrum
pearl shoal
#

ok thanks lemme see if it works

slim spindle
#
# bot.py
import os

import discord
from discord.ext import commands

#client = discord.Client()
client = discord.Client(intents=discord.Intents.default(),proxy="http://myproxy.com:8080")

bot = commands.Bot(intents=discord.Intents.default(),proxy="https://myproxy.com:8080",command_prefix='!')
os.environ['HTTP_PROXY'] = 'http://myproxy.com:8080'
os.environ['HTTPS_PROXY'] = 'https://myproxy.com:8080'

@client.event
async def on_ready():
    print(f'{client.user} has connected!')

@bot.command()
async def dosomething(ctx):
    await ctx.send('I did something')

@client.event
async def on_message(message):
    if message.author == client.user:
        return
    if message.content.startswith('$hello'):
        await message.channel.send('Hello!')

client.run('TOKEN')

storm rose
slim spindle
#

How do i run behind proxy ? this script is working but not working when any request

silk fulcrum
#

@storm rose so you type !kick @member and it doesnt kick?

storm rose
#

yes

pearl shoal
#

whenever i send a essage in the channel it shows this in console

slim spindle
#

when I google for request discord using htpps

silk fulcrum
#

well code looks nice maybe problem is outside, you could've not saved file or did not reload the bot @storm rose

pearl shoal
slim spindle
#

can anyone help ? my server using proxy.

silk fulcrum
#

wow how many problems and only me helper

slim spindle
slim spindle
pearl shoal
silk fulcrum
pearl shoal
silk fulcrum
#

also @slim spindle i can't really help you since I didn't ever work with proxy and if problem is with it then it's probably not this channel topic. But what do I know about it...

warm flame
#

guys is it possible to make a sort of map game using discord.py?

#

or is it better using js?

shrewd apex
#

why do u have both client and bot?💀

pearl shoal
shrewd apex
#

depends on skills

#

not language mostly

warm flame
#

but i dont know much javascript

shrewd apex
#

python is so much simpler than js if u are not able to make in python it's gonna be gg in js

warm flame
#

ok thxs

silk fulcrum
#

hm, so now that all problems are solved (i guess), I can return to my problem, what colour to use in help embed pithink

shrewd apex
#

random()

pearl shoal
#

ayooooooooo Master32 tytytytytytytyytytytyuytytyytytyytytytytytytytytytytytytyttyyt

silk fulcrum
shrewd apex
#

color won't matter much if ur help command embed looks good

pearl shoal
shrewd apex
#

so how are ur embed designing skills

silk fulcrum
shrewd apex
#

turquoise light yellow pink all look good but if people are in daymode then rip those colours are invisible

#

cyan etc

#

all colors on the softer range mostly

fading sleet
#

pandas is running when I run the code on vscode. However, there is a problem when I want to run this code by heroku and I couldn't find any reason "why it is"

silk fulcrum
pearl shoal
#

we should above 13 to be on discord right?

silk fulcrum
pearl shoal
fading sleet
vocal snow
#

Light mode is better for your eyes!

pearl shoal
#

my whole room is filled with light

#

dark mode is stilll better

shrewd apex
silk fulcrum
fading sleet
#

hey I have a problem and I couldn't fix it

shrewd apex
#

sed

fading sleet
#

y'all talk about the theme

#

???

shrewd apex
#

requirements.txt add panda there

fading sleet
silk fulcrum
shrewd apex
#

why are u asking heroku pandas module problem in discord bot channel tho pithink

fading sleet
silk fulcrum
#

pandas.djs

shrewd apex
#

!pypi pandas

unkempt canyonBOT
#

Powerful data structures for data analysis, time series, and statistics

fading sleet
shrewd apex
#

write pandas==1.4.3

fading sleet
#

ok

shrewd apex
#

write that

#

i don't see how unless u are using panda in ur discord bot

#

but what for 💀

fading sleet
#

and I use numpy. Should I write numpy as well?

fading sleet
shrewd apex
#

all 3rd party modules

#

sad SQL noises

fading sleet
silk fulcrum
#

tiktok?

shrewd apex
#

what's with ur themes💀 💀

#

it's pink now

#

and wildcard imports rip another bad idea

fading sleet
#

Otherwise I didn't use it

shrewd apex
#

master32 what's the best looking help command u ever seen👀

silk fulcrum
shrewd apex
#

hmm ic well robodanny embeds don't look that gr8 only the pagination part looks nice

#

embeds are kinda cramped

silk fulcrum
#

yeah

#

well I got some random designer and he did this for me, idk, it looks kinda good, but im not the one who can rate help commands

pearl shoal
#

nice'

dry crown
#

how does discord bot responds in a specific server works? for example Server 1 and Server 2
if I send command in Server 1 it will not reply in Server 2

silk fulcrum
#

api?

cloud dawn
#

Since Discord.py is just an API wrapper you just don't need to worry about that.

dry crown
#

I have this problem on my quiz bot like; I send answer in server 1, but it responds in server 2

silk fulcrum
#

lmao

cloud dawn
#

Then you most likely used hard coded id's.

cold sonnet
fading sleet
cold sonnet
#

:D

pearl shoal
#

can anyone help?

placid skiff
#

with?

pearl shoal
#

my bot isnt replying

#

the messages are reaching the console'

silk fulcrum
#

what's the code? what's the error (if there is)?

pearl shoal
#

no error

unkempt canyonBOT
#

Hey @pearl shoal! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me

Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!

silk fulcrum
#

reset your token

#

RN

pearl shoal
#

its just a practice bot lol

#

import discord

TOKEN = 'bottoken'
client = discord.Client()

@client.event
async def on_ready():
print(f'{client.user} Is ON')

@client.event
async def on_message(message):
username = str(message.author).split('#')[0]
username = str(client.user).split('#')[0]
user_message = message.content
channel = message.channel.name
print(f'{username}: {user_message} ({channel})')
if message.author == client.user:
return

if message.channel.name == 'spam':
if user_message.lower() == 'hello':
await message.channel.send(f'hello')
return

client.run(TOKEN)

#

console:

#

Ansh: hi (spam)

pearl shoal
#

no response from the bot

placid skiff
#

the bot will send a message when you send "hello" in a channel named "spam"

silk fulcrum
#

well you said hi, not hello

pearl shoal
#

no

#

it doesnt

pearl shoal
#

i changed it rn

placid skiff
#

then the channel name is not spam

pearl shoal
#

it is

silk fulcrum
#

then something you are telling is a lie

pearl shoal
#

join my sever

#

*server

#

sad

cloud dawn
pearl shoal
#

?

#

what does that mean\

cloud dawn
#

What version of dpy are you using?

#

1.7.3 i think.

pearl shoal
#

idk the version im new to python

#

😅

silk fulcrum
#

pip show discord

pearl shoal
silk fulcrum
#

in terminal

pearl shoal
#

hm

#

it should rrepy

#

*reply

placid skiff
#

discord.py is not beginner friendly, you need to know python to use it

pearl shoal
#

version is 1.7.3

#

it responded 2 mins ago idk what happened

cloud dawn
#
import discord

TOKEN = 'bottoken'
client = discord.Client(intents=discord.Intents.all())


@client.event
async def on_ready():
    print(f'{client.user} Is ON')

@client.event
async def on_message(message):
    if message.author.bot:
        return

    print(f"{message.author.name}: {message.content} ({message.channel.name})")

    if message.channel.name == 'spam':
        if message.content.lower() == 'hello':
            return await message.channel.send(f'hello')

client.run(TOKEN)
slate swan
#

What was the class to add_item a button?

cloud dawn
#

!d discord.ui.View

unkempt canyonBOT
#

class discord.ui.View(*, timeout=180.0)```
Represents a UI view.

This object must be inherited to create a UI within Discord.

New in version 2.0.
slate swan
#

panda pepeShy

placid skiff
#

Hello ash

slate swan
pearl shoal
zealous jay
#

a

#

probably need to activate intents from the developer portal

slate swan
#

you shouldnt see that there is an error, rather see what the error actually is

silk fulcrum
cloud dawn
slate swan
pearl shoal
slate swan
#

or did you

pearl shoal
#

no i didnt

slate swan
#

show code?

#

if you didnt then it should work fine

pearl shoal
#

nvm fixed it

slate swan
#

nice

pearl shoal
#

idk what i fixed but it started working

slate swan
#

...

pearl shoal
#

import discord

TOKEN = 'token'
client = discord.Client()

@client.event
async def on_ready():
print(f'{client.user} Is ON')

@client.event
async def on_message(message):
if message.author.bot:
return

print(f"{message.author.name}: {message.content} ({message.channel.name})")

if message.channel.name == 'spam':
    if message.content.lower() == 'hello':
      await message.channel.send(f'hello')
      return

client.run(TOKEN)

unkempt canyonBOT
#

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.

vale wing
#

Sussy client

slate swan
#

imagine using Client pepecry

pearl shoal
#

?

silk fulcrum
vale wing
#

This is sus too

pearl shoal
#

😦

silk fulcrum
#

AutoShardedBot 👼

vale wing
#

You can compare by channel ID

#

f"hello" f-string without interpolation

pearl shoal
#

wait now iknow what pandabweer did wrong he wrote "return await message.channel.send(f'hello')

vale wing
#

This code is indeed sus

pearl shoal
#

anything what everybody is saying

slate swan
# pearl shoal then?

use the commands extension, you can simply create commands like

from discord.ext import commands

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

@bot.command()
async def spam(ctx: commands.Context) -> None:
  if ctx.channel.name == "spam":
    return await ctx.send("hello")

bot.run(token)

spam can be invoked using !spam UniSips

vale wing
vale wing
#

Cause send returns Message (i forgor)

pearl shoal
vale wing
slate swan
#

wha-

pearl shoal
#

ahh

slate swan
#

god

pearl shoal
#

and then return under it

slate swan
#

and I got ignored UniSips

slate swan
#

ok

vale wing
#

What do you guys use for bot internal logging

#

Just interesting

silk fulcrum
pearl shoal
#

why is my script sus it works fine

vale wing
silk fulcrum
vale wing
silk fulcrum
novel apexBOT
#

This is not a Modmail thread.

silk fulcrum
#

bruh wrong server

zealous jay
pearl shoal
#

guys i have a question

vale wing
#

What's the number of that april 1st PEP

slate swan
pearl shoal
#

my friend tried to do pip install discord in console and after installation

#

he did import discord and it didntt work

vale wing
#

Same question I am developing unity game

silk fulcrum
slate swan
#

imagine

slate swan
vale wing
slate swan
vale wing
#

I have no idea what I am making it for and its current content makes no sense

silk fulcrum
slate swan
pearl shoal
#

i am trying to make a bot for the past 2 years first i used discprd.js that was so complicated then last month i found that we can do it through python also

vale wing
#

Tbh I learned quite a lot while making this concrete game

silk fulcrum
pearl shoal
#

flex - ||im on an💀 i3 dell laptop

slate swan
slate swan
zealous jay
#

I learned python by creating a bot for a community

vale wing
pearl shoal
#

where are you guys from?

zealous jay
#

and well now I got my own bot

zealous jay
pearl shoal
#

nic

#

nicee

#

im trying to make a Moderation bot

#

idk how to

#

lol

slate swan
silk fulcrum
pearl shoal
silk fulcrum
silk fulcrum
pearl shoal
#

no its for my server]

#

PokeMod

#

we will ban people using pokemon attacks lame but i like it so idc

vale wing
# slate swan lmao

My last thought was to make a "nerd bot" that would disagree with every statement in a channel and say "um, actually"

zealous jay
#

did someone here use contabo as a host for a bot?

vale wing
#

What is that

zealous jay
#

a host

zealous jay
#

Hosting website

vale wing
#

I don't know any other hosts than ubuntu server

silk fulcrum
pearl shoal
silk fulcrum
zealous jay
#

How is he named

vale wing
#

One dude tried to run one of my open source bots that uses postgres and docker on replit

pearl shoal
vale wing
#

And was like "how to run it"

silk fulcrum
pearl shoal
#

why is it bad

vale wing
#

The only thing that seems ok about that is poetry

pearl shoal
#

its same as vscode

zealous jay
#

no

silk fulcrum
vale wing
#

Vscode is much much better

zealous jay
#

👆

pearl shoal
#

i cant keep my laptop on whole day

vale wing
#

Build some server from old computer parts if you have some

silk fulcrum
#

for hosting this

vale wing
#

Like I did

vale wing
pearl shoal
#

this is my first laptop...

zealous jay
#

not everyone can build one

#

or have good wifi

vale wing
#

I had some random old computer parts like intel pentium and 3gb of ddr3

#

It works well 😀

pearl shoal
#

why am i automatically added to these "EGIRL CLUB | CHATTING" servers

silk fulcrum
#

lmao dont click random links

vale wing
#

Probably some bad oauth2 link with guilds.join scope

pearl shoal
vale wing
pearl shoal
#

i dont addd random bots

vale wing
#

While I was making dashboard for bot with django I learned their oauth2 inside out

pearl shoal
#

how to make kick command?

vale wing
#

Well only with identify and guilds scope but who cares

pearl shoal
#

owowowowowowowowoowowowow

vale wing
vale wing
#

!d discord.Member.kick

unkempt canyonBOT
#

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

Kicks this member. Equivalent to [`Guild.kick()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.kick "discord.Guild.kick").
pearl shoal
#

kick user cmd

slate swan
#

What is cogs?

vale wing
pearl shoal
silk fulcrum
unkempt canyonBOT
#

class discord.ext.commands.Cog(*args, **kwargs)```
The base class that all cogs must inherit from.

A cog is a collection of commands, listeners, and optional state to help group commands together. More information on them can be found on the [Cogs](https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html#ext-commands-cogs) page.

When inheriting from this class, the options shown in [`CogMeta`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CogMeta "discord.ext.commands.CogMeta") are equally valid here.
silk fulcrum
#

basically categories

#

with commands

vale wing
#

Yeah

silk fulcrum
#

or groups

vale wing
#

Classes for better organisation

vale wing
silk fulcrum
#

yeah

pearl shoal
#

CAN ANYONE TELL ME CMD TO KICK

#

KICK USER]

#

no

#

?p'

silk fulcrum
#

!d discord.Member.kick

unkempt canyonBOT
#

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

Kicks this member. Equivalent to [`Guild.kick()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.kick "discord.Guild.kick").
pearl shoal
#

ok

silk fulcrum
#

noone will spoonfeed you here

pearl shoal
#

sad

#

das

slate swan
#

How can i add drop down menu in modal?

#

!d discord.ui.Modal.add_item

unkempt canyonBOT
#

add_item(item)```
Adds an item to the view.

This function returns the class instance to allow for fluent-style chaining.
slate swan
slate swan
slate swan
vale wing
slate swan
#

it supports SelectMenus too

vale wing
#

Interesting I didn't know

slate swan
#

doesnt show up on mobile phones tho

slate swan
#

its been more than a month ig

#

ic

#

There is a way to add menu to modal but idk how

cloud dawn
slate swan
#

Wow real interesting

vale wing
#

I can't find any mentions about modals in discord api docs actually lmao

#

They only mention modals together with text inputs

golden tapir
#

how can i make it that some people with the right roles use certain commands
like i have a reset command i only want server managers using it

vale wing
#

Is it a single guild bot

silk fulcrum
#

!d discord.ext.commands.has_permissions

unkempt canyonBOT
#

@discord.ext.commands.has_permissions(**perms)```
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 has all of the permissions necessary.

Note that this check operates on the current channel permissions, not the guild wide permissions.

The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions").

This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingPermissions "discord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
slate swan
#

!d discord.ext.commands.has_any_role "right roles"

unkempt canyonBOT
#

@discord.ext.commands.has_any_role(*items)```
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 **any** of the roles specified. This means that if they have one out of the three roles specified, then this check will return True.

Similar to [`has_role()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.has_role "discord.ext.commands.has_role"), the names or IDs passed in must be exact.

This check raises one of two special exceptions, [`MissingAnyRole`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingAnyRole "discord.ext.commands.MissingAnyRole") if the user is missing all roles, 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 [`MissingAnyRole`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingAnyRole "discord.ext.commands.MissingAnyRole") 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")
golden tapir
#

when i change the manage_messages to mod it gives me a error

silk fulcrum
#

oh yeah that is also a thing

silk fulcrum
golden tapir
#

i did that

#

but i get error

silk fulcrum
golden tapir
#

what

silk fulcrum
#

click the reply

golden tapir
#

i did i am on it

silk fulcrum
#

you use has_permissions

golden tapir
#

do u want to sere the error

silk fulcrum
#

no

#

you use has_permissions

golden tapir
#

ok how fix then

silk fulcrum
#

use has_any_role

golden tapir
#

oh

slate swan
silk fulcrum
#

oh sorry forgot do disable it(

slate swan
#

I didnt have to over react pepe_exit

#

I was kidding

paper sluice
spare urchin
#
@nextcord.slash_command(name='vemojiinfo', description='Shows info about an emoji')
  async def infofemoji(self, interaction: nextcord.Interaction, emoji: str=SlashOption(description='Valid emoji in the server')):
   try:
    emoji = await emoji.guild.fetch_emoji(emoji.id)
   except:
     return await interaction.response.send_message('Couldnt find the emoji', ephemeral=True)
   name = emoji.name
   id = emoji.id
   anime = emoji.animated
   by = emoji.user
   creation = emoji.created_at
   link = emoji.url

   embed = nextcord.Embed()
   embed.title = ("Emoji Info")
   embed.description = (f"Showing info of `{name}` emoji")
   embed.add_field(name="__Emoji Name__", value=name)
   embed.add_field(name="__Emoji ID__", value=id)
   embed.add_field(name="__Animated?__", value=anime, inline=False)
   embed.add_field(name="__Created By__", value=by, inline=False)
   embed.add_field(name="__Created At__", value=creation, inline=True)
   embed.set_thumbnail(url=link)
   embed.timestamp = dt.datetime.utcnow()
   embed.color = (3066993)
   await interaction.response.send_message(embed=embed)

I'm trying to make an emoji info command...
But problem is whenever i give any emoji it shows could not find emoji [ as given in exception ]
Is there a way to solve this ?

vale wing
#

Typehint emoji with nextcord.Emoji

silk fulcrum
#

not with str

vale wing
#

You will automatically get emoji object

spare urchin
#

But you can't use nextcord.Emoji in slash commands...

#

As it shows

vale wing
#

Oh yeah right

#

!d discord.ext.commands.EmojiConverter

unkempt canyonBOT
#

class discord.ext.commands.EmojiConverter(*args, **kwargs)```
Converts to a [`Emoji`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Emoji "discord.Emoji").

All lookups are done for the local guild first, if available. If that lookup fails, then it checks the client’s global cache.

The lookup strategy is as follows (in order)...
vale wing
#

Then use this

placid skiff
#

Converters require a Context object, I don't remember if an Interaction works too

vale wing
#

It does

#

Interaction is much alike context

mortal cosmos
#

how can you make slash command with discord py 2.0 ver with cogs

paper sluice
slate swan
#

is there something like on_mention???

grim oar
#

on_message, check message.mentions

#

!d discord.Message.mentions

unkempt canyonBOT
#

A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.

Warning

The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.

ivory wraith
#

how would I get discord.py to use asqlite's async loop with setup_hook?

short trout
#
import asyncio
import discord
from discord.ext import commands
from discord import app_commands

class MySlashCog(commands.Cog):
    def __init__(self, bot: commands.Bot) -> None:
        self.bot = bot
    
    @app_commands.command(name="ping", description="...")
    async def _ping(self, interaction: discord.Interaction):
        await interaction.response.send_message("pong!")
    
class MySlashBot(commands.Bot):
    def __init__(self) -> None:
        super().__init__(command_prefix="!", intents=discord.Intents.default())
    
    async def setup_hook(self) -> None:
        await self.add_cog(MySlashCog(self))
        self.tree.copy_global_to(discord.Object(id=serveridlolwhatdoyouwantuhhhh))
        await self.tree.sync()
        
bot = MySlashBot()

async def main():
    await bot.start("mytokenjusthidedlol")

asyncio.run(main())

silk fulcrum
#

main should be without brackets

#

asyncio.run(main)

short trout
silk fulcrum
#

also why don't u just do bot.run('token') at the end of file without all that awaiting stuff

short trout
silk fulcrum
#

bot.run

#

not bot.start

short trout
#

ye that only

short trout
short trout
silk fulcrum
#

full traceback?

slate swan
#

is there someting like on_join??

wicked atlas
unkempt canyonBOT
#

discord.on_member_join(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") joins a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").

This requires [`Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
short trout
silk fulcrum
unkempt canyonBOT
#

discord.on_guild_join(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild") is either created by the [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") or when the [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") joins a guild.

This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
silk fulcrum
wicked atlas
slate swan
short trout
silk fulcrum
short trout
# wicked atlas Can you send your full code right now?
import discord
from discord.ext import commands
from discord import app_commands


class MySlashCog(commands.Cog):
    def __init__(self, bot: commands.Bot) -> None:
        self.bot = bot
    
    @app_commands.command(name="ping", description="...")
    async def _ping(self, interaction: discord.Interaction):
        await interaction.response.send_message("pong!")
    
class MySlashBot(commands.Bot):
    def __init__(self) -> None:
        super().__init__(command_prefix="!", intents=discord.Intents.default())
    
    async def setup_hook(self) -> None:
        await self.add_cog(MySlashCog(self))
        self.tree.copy_global_to(discord.Object(id='id'))
        await self.tree.sync()
        
bot = MySlashBot()

bot.run("token")
silk fulcrum
slate swan
short trout
wicked atlas
slate swan
#
@bot.event
discord.on_join
silk fulcrum
#

this is what you showed

short trout
#

my main dont have any problem id think

silk fulcrum
#

and this is full traceback

short trout
#

ok a sec

wicked atlas
silk fulcrum
#

wrong reply

wicked atlas
#

oh woops

paper sluice
short trout
#

?

wicked atlas
#

Do you have the full traceback? We should really figure out why the normal method isn't working first before you start to do other methods

paper sluice
short trout
#

ye ok i wil try

#

oh that seems working without giving an err

#

but cant see the slash cmds in the server

silk fulcrum
#

did you put a tick near application.commands when creating oauth link?

#

i should've ticked it so you can see, me dumb

short trout
#

ye i did

short trout
short trout
weary dragon
#

Hey i was wondering if u could use an account token instead of a bot token to manipulate the account

paper sluice
crystal glen
#
@client.command()
@commands.has_permissions(administrator=True)
async def createvoice(ctx, *, channel_name: str, number: int):
    for x in range(number):
        await ctx.guild.create_voice_channel(f"{channel_name}")

I want to make number of channels with a custom name
example:
?createvoice Ara 10

#

But it doesn't work...

weary dragon
#

nvm then

crystal glen
#
@client.command()
@commands.has_permissions(administrator=True)
async def createvoice(ctx, channel_name: str, number: int):
    for x in range(number):
        await ctx.guild.create_voice_channel(f"{channel_name}")

#

Will this work?

short trout
crystal glen
#

Oh yeah, It works

#

Thanks ❤️

wicked atlas
#

👍

crystal glen
#

How do I specify the category (with ID)?

short trout
silk fulcrum
unkempt canyonBOT
#

await create_voice_channel(name, *, reason=None, category=None, position=..., bitrate=..., user_limit=..., rtc_region=..., video_quality_mode=..., overwrites=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

This is similar to [`create_text_channel()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.create_text_channel "discord.Guild.create_text_channel") except makes a [`VoiceChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.VoiceChannel "discord.VoiceChannel") instead.

Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") instead of `InvalidArgument`.
crystal glen
silk fulcrum
#

create_voice_channel(..., category=ctx.guild.get_channel(category_id))

crystal glen
#
@client.command()
@commands.has_permissions(administrator=True)
async def createvoice(ctx, channel_name: str, number: int, category_name: str):
    for x in range(number):
        await ctx.guild.create_voice_channel(f"{channel_name}", category=category_name)
paper sluice
short trout
#

rather than the default help cmd nonthing works now

wicked atlas
crystal glen
#
@client.command()
@commands.has_permissions(administrator=True)
async def createvoice(ctx, channel_name: str, number: int, category_id: str):
    for x in range(number):
        await ctx.guild.create_voice_channel(f"{channel_name}", category=ctx.guild.get_channel(category_id))
#

I did this, Will it work?

silk fulcrum
wicked atlas
#

ah yeah that too

crystal glen
#

yeah it works

paper sluice
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.

crystal glen
#

Thanks guys lol ❤️

wicked atlas
slate swan
#

anyone know how to use time in a bot status?

silk fulcrum
slate swan
#

current time

unkempt canyonBOT
#

discord.utils.utcnow()```
A helper function to return an aware UTC datetime representing the current time.

This should be preferred to [`datetime.datetime.utcnow()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow "(in Python v3.10)") since it is an aware datetime, compared to the naive datetime in the standard library.

New in version 2.0.
#

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

Changes the client’s presence.

Example

```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
```   Changed in version 2.0: Removed the `afk` keyword-only parameter...
crystal glen
#
@client.command()
@commands.has_permissions(administrator=True)
async def allchannels(ctx, *, new_channel: str, category_id: int):
    for channel in ctx.guild.channels:
        try:
            await channel.edit(name=f"{new_channel}", category=ctx.guild.get_channel(category_id))
        except Exception as e:
            print(e)
            continue

I want to change all channel name is a specified category, But I get an error which is:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: allchannels() missing 1 required keyword-only argument: 'category_id'

zealous jay
#

Did you pass category id properly?

crystal glen
#

Well, I don't know

zealous jay
#

try this

karmic haven
crystal glen
#

I tried this tho

karmic haven
#

Hmm that seems like it should be correct

crystal glen
#

Yes

zealous jay
#
async def allchannels(ctx, new_channel: str, category_id: int):
#

i think the * may be the problem

#

when you call the command but im not sure

karmic haven
#

My thought as well, but discord.py has been some time for me

crystal glen
zealous jay
#

okay so it kinda worked

karmic haven
#

Well it worked

zealous jay
#

at least you can pass the id now

karmic haven
crystal glen
karmic haven
crystal glen
#

Well, It doesn't have to make channels

#

It has to rename them

karmic haven
#

O wait i misread the code mb

crystal glen
#

it's ok

zealous jay
#

Uuh

#

your loop is

#

doing all of that for every channel in the guild

karmic haven
#

Oh i see the problem

crystal glen
#

That's why I'm giving a category ID

zealous jay
#

but you are going trough every channel tho

karmic haven
#

The loop goes over every channel in your server, and when editing the channel, it places it in the category with category_id, this causes your bot to place all channels in there, filling it up

zealous jay
karmic haven
#

What i believe you are trying to do is rename all channels in a category you specified right? @crystal glen

karmic haven
crystal glen
#
@client.command()
@commands.has_permissions(administrator=True)
async def allchannels(ctx, new_channel: str, category_id: int):
    for channel in ctx.guild.channels.category.id == category_id:
        try:
            await channel.edit(name=f"{new_channel}")
        except Exception as e:
            print(e)
            continue
#

I did this

zealous jay
#

i don't think you can compare in that way

#

after the in

karmic haven
#

There is discord.TextChannel.category and discord.TextChannel.category_id

crystal glen
#

How do I use it?

karmic haven
#

What exactly are you trying to do?

crystal glen
#

Rename all the channels that are in a category

zealous jay
#

its hard to code on cellphone

karmic haven
#

If you only want to rename channels in a category, you dont need to loop over all the channels in a server, only over the channels in that category

#

If you get the category object, you can access it's channels and loop over those

zealous jay
#

what about doing this after the try

if channel.category_id == category_id:
       try:
               ...

crystal glen
#
@client.command()
@commands.has_permissions(administrator=True)
async def allchannels(ctx, new_channel: str, category_id: int):
    for channel in ctx.guild.channels:
        if channel.category_id == category_id:
            try:
                await channel.edit(name=f"{new_channel}")
            except Exception as e:
                print(e)
                continue
zealous jay
#

try that

crystal glen
#

It worked 🙂

zealous jay
#

good

karmic haven
crystal glen
#

Thank you guys

karmic haven
#

Always

crystal glen
#

❤️

zealous jay
#

i was typing that at the same time you sent it haha

#

no problem

crystal glen
#

Yeah thanks again ❤️

karmic haven
#

Damn it's been a while since i used discord.py, i've been much more about doing the api calls and the gateway communications myself

#

Much more fun imo, really digging through the docs

slate swan
crystal glen
#

?q=Araso+The+Best

ashen notch
#

The let me google that for you is bouncing

#

We have it blacklisted because so many people used it to be a dick

#

So if you repaste your code with that URL replaced, it'll go through just fine

crystal glen
#

bRUH

silk fulcrum
#

!e py query = "Araso The Best" print(query.replace(' ', '+'))

unkempt canyonBOT
#

@silk fulcrum :white_check_mark: Your 3.11 eval job has completed with return code 0.

Araso+The+Best
crystal glen
#

Will this work?

rancid grail
#

no as str.replace isnt inplace

crystal glen
rancid grail
#

search_term = search_term.replace(...) will work

crystal glen
#

Thanks guys ❤️

ivory wraith
#

how would I get setup_hook to use the asqlite async loop?

maiden fable
#

I haven't really looked at dpy 2.0, but there should be a loop kwarg in the commands.Bot class

#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a Discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.

Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client"), this class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree "discord.app_commands.CommandTree") and is automatically set upon instantiating the class.

async with x Asynchronously initialises the bot and automatically cleans up.

New in version 2.0.
maiden fable
#

Nvm I'm wrong

silk fulcrum
ivory wraith
# silk fulcrum wdym "use the asqlite async loop"?

I'm not sure, to be honest? I don't understand async too much.
I got this answer to a problem I had, though, and I'm not sure how to implement it.

You should create the connection in dpy's async context. Try subclassing commands.Bot and override setup_hook method to make your connection and set it as a class attribute.

silk fulcrum
whole sparrow
#

for my bot, how can I send to a specific channel when I dont have self.bot in the class that Im using, ive been using interaction.followup but I want to now change to send to a specific channel

#
await i.followup.send(embed=embed)

I have this currently but how can I change it so I can send to a specific channel? Im not good with interactions and such

vocal snow
whole sparrow
#

Yep

vocal snow
#

Then you can use interaction.guild.get_channel

#

!d discord.Guild.get_channel

unkempt canyonBOT
#

get_channel(channel_id, /)```
Returns a channel with the given ID.

Note

This does *not* search for threads.

Changed in version 2.0: `channel_id` parameter is now positional-only.
whole sparrow
#

ooo thats exactly what I was looking for thank you

#

didnt know interaction had that

#

thanks homie

whole sparrow
#

yh just assumed interactions didnt have that feature shouldve looked first

#

thanks

crystal glen
#
@client.event()
async def on_member_join(member : discord.Member):
    is_verified_bot = member.public_flags.verified_bot
    if member.bot:
        if is_verified_bot:
            print(member, "is verified!")
        else:
            print("You are a bot, but you are not verified!")

Why this isn't working?

silk fulcrum
#

error?

crystal glen
#

I'm trying to check if a bot is verified or not

silk fulcrum
#

uh yeah

#

event without brackets

crystal glen
#

wdym

silk fulcrum
#

you do @client.event()
should be @client.event

crystal glen
#

bruh

ivory wraith
silk fulcrum
#

I hope you didnt't do @bot.command in class

vale wing
#

That decorator is not a staticmethod and please name classes in UpperCamelCase

sick birch
vale wing
crystal glen
#
@client.event
async def on_member_join(member : discord.Member):
    is_verified_bot = member.public_flags.verified_bot
    if member.bot:
        if is_verified_bot:
            print(member, "is verified!")
        else:
            await member.kick()
            print(member, "is kicked")

Muhahahaha

ivory wraith
vale wing
#

Unverified bots kicker

sick birch
#

Since you can only have one event loop at a time (correct me if i'm wrong)

vale wing
#

@Robin J#2415 hi there, could you tell me about this

#

Discord mentions smoking smth again

#

I can't ping you at all lol

sick birch
#

Once the necessary people have approved your PR, then it's just a matter of time until the right person comes along and merges them

vale wing
#

Ok thanks

ivory wraith
vale wing
crystal glen
vale wing
#

I mean code style

silk fulcrum
#

PEP

sick birch
# ivory wraith I'm sorry; I still don't understand. Could you explain again? I've been confused...

Yup. let me try to explain using another example, aiohttp, which is a common usecase in discord bots:

class MyBot(commands.Bot):
  def __init__(self, ...) -> None:
    """ Regular bot initialization """
    super().__init__(...)
    ...
  
  async def setup_hook(self) -> None:
    self.session = aiohttp.ClientSession()

In this example, aiohttp.ClientSession() is created with the discord.py asynchronous event loop as a context. This is because it's inside of an asynchronous function, which can only have one event loop. Same deal for your asqlite or any other asynchronous database connection, if you do it inside of setup_hook, it'll automatically get the asynchronous context

#

I think what you think is that different modules (e.g discord.py, asqlite, etc) have their own event loops that they work on, which is not necessarily true. Your program as a whole as one big event loop, which would be the "context"

ivory wraith
#

Thank you. This cleared things up immensely.

sick birch
zealous jay
#

So.. if I want to get the reason I need to fetch the audit logs?

sick birch
#

Luckily it should be the very first audit log

zealous jay
#

well the bot already works like that but I was trying to optimize it for the 2.0 version haha

zealous jay
#

thanks!

ivory wraith
uneven gull
#

show code

silk fulcrum
ivory wraith
uneven gull
#

everyone makes mistakes and thats fine, actually a good thing if you keep learning from them

ivory wraith
#

it worked.. I'm ecstatic

#

or rather

#

it got a different error

#

but that is one I can deal with

uneven gull
#

see and there you went a step further

silk fulcrum
uneven gull
austere vale
#
  async def on_message_delete(self, message):
    embed=nextcord.Embed(title="Message delete", description= f"Deleted by {message.author.mention} in {message.channel.mention}\nMessage:{message.content}",color=0xfd9fa1, timestamp=datetime.datetime.utcnow())

instead of message.author.mention, what can i put so that it grabs the person who deleted the message, not the person who wrote the message?

silk fulcrum
austere vale
unkempt canyonBOT
#

async for ... in audit_logs(*, limit=100, before=..., after=..., oldest_first=..., user=..., action=...)```
Returns an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") that enables receiving the guild’s audit logs.

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

Examples

Getting the first 100 entries:

```py
async for entry in guild.audit_logs(limit=100):
    print(f'{entry.user} did {entry.action} to {entry.target}')
```...
uneven gull
#

i ment who ran the delte_message command

silk fulcrum
#

wait wha

austere vale
#

its not a command its an event

#

i'll try looking at the audit log

uneven gull
#

oh i got i wrong sorry my bad

slate swan
#

Using python async def on_message(message):
How does one get the message.author's icon url?

slate swan
#

!d discord.Asset.url

unkempt canyonBOT
silk fulcrum
#

ehh

slate swan
#

Member.avatar returns an Asset object lol

silk fulcrum
#

oh wait, okimii, hi there!

slate swan
#

message.author.avatar_url?

slate swan
slate swan
silk fulcrum
slate swan
#

👁️👁️

#

Thanks guys. print avatar_url worked for me

#

❤️

silk fulcrum
#

1.7.3

slate swan
zealous jay
#

Is there a limit for fetching the audit log for bans? Or should I use guild.bans() instead?

#

Because fetching the audit log also gives me the user who banned the target

#

And I would prefer to do that

zealous jay
#

nice then

#

thanks

outer parcel
#

so i have this code

#

but how do i get the channel from interaction

#

im used to do ctx.channel

#

but how would i do it for interaction

silk fulcrum
#

absolutely same

#

!d discord.Interaction.channel

unkempt canyonBOT
outer parcel
#

oh ok ty

tidal hawk
#

ig when you load cogs in your main file with .load_extension() it searches for setup() function inside each cog

#

which then adds the cog

spice kindle
#

is there a method that can be used to cleanly stop the bot with a slash command?

slate swan
#

little unreleated to coding but can a tag be used inside of a box

#

like @tag here

hardy yoke
#

@PJ Matlock#0001

slate swan
#

thank you

dry kelp
spice kindle
#

how come "level" is not defined (line 21)? I already declared it on line 16

river linden
#

async I think

#

it's not within the async context so it doesn't see it defined

vocal snow
spice kindle
#

how can i fix it?

vocal snow
#

self.level

spice kindle
#

ohh i get it now

flat solstice
dry kelp
#

https://hastebin.com/yerafaciri.rust - error

whitelisted = fields.ManyToManyField("Bot.UserModel", on_delete=fields.SET_NULL, null=True, related_name="whitelisted")
vanity_whitelisted = fields.ManyToManyField("Bot.UserModel", on_delete=fields.SET_NULL, null=True, related_name="vanity_whitelisted")

That error is coming from those 2 lines...

@sick birch do u mind checking this out?

sick birch
dry kelp
#

its not really about database

#

idk if u remember me long time ago.. u told me to change from json to SQL

#

and i can tell is a lot better.. a lot of work but my last 2 modules are being a pain in the ass lol

sick birch
dry kelp
#

i asked ther etoo

#

there too

spice kindle
sick birch
spice kindle
sick birch
#

Looks like member is None for some reason

spice kindle
#

hmm

limber bison
#

How can I create vc vai bot in a fixed catagory ?

vocal snow
#

!d discord.CategoryChannel.create_voice_channel

unkempt canyonBOT
#

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

A shortcut method to [`Guild.create_voice_channel()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.create_voice_channel "discord.Guild.create_voice_channel") to create a [`VoiceChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.VoiceChannel "discord.VoiceChannel") in the category.
slate swan
slate swan
#

pycord ofc

calm ridge
#

Hi can someone help me with this bot not working?
I got it from github
https://github.com/jamal0025/Discord-Success-Bot
i keep getting an error when i paste the image
Image
Here is the code
https://hastebin.com/fagexivuva.py

GitHub

Your average discord success reposter that includes a delete function. - GitHub - jamal0025/Discord-Success-Bot: Your average discord success reposter that includes a delete function.

slate swan
#

what's the error

calm ridge
#

Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\16479\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\16479\Downloads\Discord-Success-Bot-master\Discord-Success-Bot-master\main.py", line 37, in on_message
image_url = message.attachments[0]['url']
TypeError: 'Attachment' object is not subscriptable

slate swan
#

[0].url

calm ridge
slate swan
#

and there's so much wrong with the code, consider rewriting it urself

calm ridge
slate swan
compact axle
#

i am making the amogus game in python

#

how does this look

slate swan
compact axle
#

python.exe4:22PM

#

oops

calm ridge
rapid charm
#

does anyone can help me on #help-pretzel im so confused about the new error

gloomy plinth
#

hi guys, im making a discord bot and am trying to host my bot using heroku. everything is working except for when I try to run my bot token, i get

2022-08-04T02:28:36.236205+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/boto/s3/connection.py", line 188, in __init__
2022-08-04T02:28:36.236309+00:00 app[worker.1]:     super(S3Connection, self).__init__(host,
2022-08-04T02:28:36.236311+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/boto/connection.py", line 568, in __init__
2022-08-04T02:28:36.236464+00:00 app[worker.1]:     self._auth_handler = auth.get_auth_handler(
2022-08-04T02:28:36.236466+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/boto/auth.py", line 1018, in get_auth_handler
2022-08-04T02:28:36.236754+00:00 app[worker.1]:     raise boto.exception.NoAuthHandlerFound(
2022-08-04T02:28:36.236800+00:00 app[worker.1]: boto.exception.NoAuthHandlerFound: No handler was ready to authenticate. 1 handlers were checked. ['HmacAuthV1Handler'] Check your credentials```
im using configure vars in heroku
here is the line ``aclient.run(S3Connection(os.environ['TOKEN']))``
i am using boto ``from boto.s3.connection import S3Connection``
any ideas why im getting this and how to fix it?
#

i have boto installed using pip install boto as well

slate swan
#

i want a bot that can check if someone is online on roblox and it sends a msg in a channel ive got the api and the channel stuff done idk how to make it so when someone gets online it says

slate swan
#

Guys.

#

I have an error.

#

File "main.py", line 2
from discord
^
SyntaxError: invalid syntax

#

How do I fix it?

ivory remnant
#

Can anyone tell me why my bot isnt responding to my commands

#

Only one function is working

kindred kernel
# ivory remnant Can anyone tell me why my bot isnt responding to my commands
kindred kernel
unkempt canyonBOT
#

error_handler.py lines 69 to 72

else:
    # All other Errors not returned come here. And we can just print the default TraceBack.
    print('Ignoring exception in command {}:'.format(ctx.command), file=sys.stderr)
    traceback.print_exception(type(error), error, error.__traceback__, file=sys.stderr)```
kindred kernel
#

you either do from discord import something or import discord

slate swan
kindred kernel
slate swan
#

Under it, I wrote from discord

#

And then it gave me an error.

kindred kernel
#

it cannot just be from discord, you should consider importing something from it

#

like from discord import Embed

#

or from discord.ext import commands

slate swan
#

Oh.

#

It gave me an error.

#

Of the first text.

kindred kernel
#

what error?

slate swan
#

Import discord

kindred kernel
#

show the error..

slate swan
#

Traceback (most recent call last):
File "main.py", line 1, in <module>
import discord
File "/home/runner/SwiftIrresponsibleCarat/venv/lib/python3.8/site-packages/discord/init.py", line 69, in <module>
clientrun(the token)
NameError: name 'clientrun' is not defined

KeyboardInterrupt

kindred kernel
#

client**.**run

slate swan
#

Oh.

kindred kernel
#

there is a dot

slate swan
#

I did.

#

It's already on .

kindred kernel
#

nope

#

i see that it is clientrun

#

not client.run

slate swan
#

it said client.run (the token)

kindred kernel
#

nope

#

i absolutely see clientrun

#

without a dot between client and run

slate swan
#

In line 39 AKA last line, it says client.run

kindred kernel
#

huh wait this error is something weird

slate swan
#

That's what I'm saying.

kindred kernel
#

it says about discord package's line 69

slate swan
kindred kernel
#

discord shouldn't even use clientrun

#

that is not a thing for lib

slate swan
#

Well, how will the bot turn on?

kindred kernel
#

did you probably accidentaly go into that file /home/runner/SwiftIrresponsibleCarat/venv/lib/python3.8/site-packages/discord/init.py and write that line?

slate swan
#

I don't know.

kindred kernel
#

anyways open it and find 69'th line

#

and show the code around it

slate swan
#

There isn't.

kindred kernel
#

i wanna see what needs that

slate swan
#

It's 39 as last line

kindred kernel
#

open not your file

#

but this one /home/runner/SwiftIrresponsibleCarat/venv/lib/python3.8/site-packages/discord/__init__.py

slate swan
#

Oh, yeah, I clicked it.

kindred kernel
#

it is the file which raises an error

slate swan
#

How do I fix it?

kindred kernel
#

show me the code like from 65'th to 75'th line

slate swan
kindred kernel
#

no

#

in that file

slate swan
#

I'm using replit.

kindred kernel
#

huh?

slate swan
#

I don't know if I saved.

kindred kernel
#

can you reinstall discord package there?

#

that'll probably fix it

slate swan
#

How?

#

I'm new to coding.

kindred kernel
#

well, you somehow installed it, right?

#

so there should be the way to uninstall it

slate swan
#

I'm not sure.

kindred kernel
#

and install again

kindred kernel
#

Or maybe you wrote dpy yourself 😳

slate swan
#

I'm not sure.

#

I need help.

kindred kernel
#

well, I don't use repl.it and Idk how to use, so my help is: reinstall discord.py package. Idk how, also, dont use repl.it

slate swan
#

Oh.

kindred kernel
#

here is why you shouldn't use repl.it

slate swan
#

Oh.

#

Is it just me or your username went lighter?

kindred kernel
#

idk

slate swan
#

how to get a message by it's id

#

can some1 help?

#

nvm thanks for the help

dense swallow
#

is it possible for me to get reasons of ban/unban from the audit logs?

silk fulcrum
unkempt canyonBOT
slate swan
#

Hey guys im getting the "too many values to unpack" error on a dict object. How do i fix this?

This is the said dictionarypy { "teamid": "emojiid", "teamid2": "emojiid2", "852995791996190751": ":D1:" }

and the command i used: for k,v in teamsdb: which triggered this error

civic fractal
#

for k,v in teamsdb.items():

slate swan
#

oh

#

thank you

#

i forgot i had to do that first 💀

civic fractal
#

np

sweet aspen
#

hey guys, just getting into bot creation and would simply like to change the text color, ive not used css before so just wondering how i go about doing that inline?

#

"""This is some colored Text"""

#

using that text box

slate swan
#

or you can use ANSI codeblocks, that's limited to desktop client only though

slate swan
cobalt jacinth
#

what are the tips for submitting discord bot for verification ?

slate swan
#

Guys am i using the or statements properly? because somethings not right i dont know what it is though.

if foRole not in message.author.roles or gmRole not in message.author.roles or hcRole not in message.author.roles:```
#

your editing it to be the embed that you used prior await message.edit(embed=embed) therefor it doesnt change

#

embed4 not embed, if u were trying to use the embed4 variable u just made

#

Ok

sweet aspen
# slate swan 😄 np

do you have any experiance with this? i can get colors to change however the bold/underlining doesnt seem to work.

slate swan
#

__You cant do this__
But you can do this

slate swan
#

ill go check the py docs on that ty

silk fulcrum
#

ok, np

#

is that a command? and what lib are you using?

slate swan
#

are you using nextcord by any chance?

#

actually nevermind

slender hamlet
silk fulcrum
slate swan
silk fulcrum
slate swan
#

oh shit i had no idea

#

when?

slender hamlet
#

Lol rlly?

slate swan
#

i've been using nextcord when it got discontinued

slender hamlet
#

Ok I am really outdated...

silk fulcrum
#

I do not clearly remember when

slender hamlet
#

You guys think the problem is coming from that "discord-py-interactions" I am using?

silk fulcrum
slate swan
#

are u sure its continued?

#

i cant find any sources about that

silk fulcrum
#

if you haven't done a lot of work

silk fulcrum
slate swan
#

oh wait nvm

silk fulcrum
#

also you can join dpy server

slate swan
#

i found it mb 😂

silk fulcrum
#

Danny keeps updating

slate swan
#

damn now i gotta switch back all my bots again

silk fulcrum
slate swan
#

I need help by using replit python.

silk fulcrum
slate swan
#

@silk fulcrum Nothing is working, I still need help.

silk fulcrum
slate swan
#

np

slate swan
slate swan
#

man gave up lol

silk fulcrum
# slate swan man gave up lol

He already came here with his problem, and I said him to reinstall discord package, he doesn't know how to do it, but i do not neither, since I don't use repl.it, that's it

silk fulcrum
#

but it's pretty bad host

slate swan
#

ik

#

i only use it for fast prototyping

#

everything ends up on main IDE which is pycharm once i've got something working

silk fulcrum
#

I don't even use those big hosts like digital ocean, I use one very cheap server and even not only for bot and it's pretty enough. I think still way better than repl.it

hardy urchin
#

‘a code block'

silk fulcrum
#
a code block