#discord-bots

1 messages · Page 443 of 1

arctic vapor
#

hmm i get a AttributeError: 'list' object has no attribute 'description'

#

triple ping rip

pale turtle
#

message.embeds returns list[discord.Embed]

arctic vapor
#

🤨 then i gotta get it separately and get the description from that? rip

slate swan
#

i don't understand, send your bot constructor

frigid apex
#

im crying

#

hahaah

slate swan
vocal shoal
#

hi..when ever i run my bot for testing it runs twice, even tho i run it once from cmd with python main.py , and i made sure that there is nothing running in the laptop's background.

#

anyone knows why?

#

i cant find the second instance.

#

also when i kill the cmd that i used to run the code, the bot goes offline..

#

wdym i didnt get it

#

so close the cmd then re-open it?

#

i use command promt

#

ok

#

i will try, thanks for the help

waxen granite
#

how to check guild premium tier in a tasks loop?

maiden fable
unkempt canyonBOT
#

The premium tier for this guild. Corresponds to “Nitro Server” in the official UI. The number goes from 0 to 3 inclusive.

maiden fable
#

U gotta get the guild with bot.get_guild and stuff

waxen granite
#

ik how to use it

#

but how do i loop it to check if the guild tier changes

maiden fable
#

U gotta store the old value in a var and the new one in another one. Then compare them

waxen granite
#

something like before.guild.premium_tier in a tasks loop

maiden fable
#

Well there is no separate event for that tbh

visual island
maiden fable
#

!d discord.on_guild_update

unkempt canyonBOT
#

discord.on_guild_update(before, after)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild "discord.Guild") updates, for example:

• Changed name

• Changed AFK channel

• Changed AFK timeout

• etc...
maiden fable
#

Hmm, could be

visual island
maiden fable
#

Etc. Hmm, it isn't defined properly what all events are triggered. Idk, time to check the intents.guild

visual island
#

lol

maiden fable
#

!d discord.Message

#

Sad, this channel has been deader now, cz of dpy

#

"deader"

visual island
#

my nitro will end soon :(

maiden fable
#

Mine in a week blobpain

fresh granite
#

#bot-commands

maiden fable
#

?

#

8 days*

visual island
#

yea same :(

maiden fable
#

7408_shrekstare I misread kylee as kiddo

#

Breh

maiden fable
#

shrug don't blame me. Life is being weird

visual island
#

r-r-r really.... blushes

maiden fable
#

Did you just see a Beluga video...?

visual island
slate swan
#

lol

maiden fable
#

Lmao

dusk creek
#

Hi

maiden fable
#

Hm?

#

enable logging. most probably ratelimited

waxen granite
#

it updates the channels on a reboot

maiden fable
#

Hmm

waxen granite
#

but after that if i create a channel it wont update

lone aurora
#

ok so yall know that you can add join msg yeye
so i added a join msg but when i add this to it

@client.event
async def on_member_join(ctx):
    role = discord.utils.get(ctx.guild.roles, name='chicoken')
    await ctx.add_roles(role)``` Why i add this to the code, it doesnt show the join msg and doesnt show any error either
waxen granite
#

anyone can help?

rare pewter
#

on_member_join also takes a member as arg(member who joins), ur supposed to give it role

lone aurora
#

how do i

rare pewter
#

Pass member as arg after ctx

#

@maiden fable @visual island potatosnuggling

lone aurora
#
@client.event
async def on_member_join(ctx, member):
    role = discord.utils.get(ctx.guild.roles, name='chicoken')
    await ctx.add_roles(role)```
#

u mean like this mate?

visual island
#

hi

maiden fable
#

Kylee sad

visual island
maiden fable
#

The emoji hehe

lone aurora
rare pewter
#

@maiden fable potatopls

visual island
rare pewter
maiden fable
visual island
lone aurora
#

ah i c thanks

waxen granite
#

@maiden fableanythingbro?

maiden fable
rare pewter
maiden fable
#

@rare pewter should be able to help you (no sarcasm)

waxen granite
#

help include

rare pewter
#

Hunter bullying me potatopls

maiden fable
#

Nah, I am fixing my VSCode

#

and deving disnake

rare pewter
#

If I knew about it I would helped
Fact is Hunter didn't taught me how to do that STARE

lone aurora
#
@client.event
async def on_member_join(ctx, member):
    role = discord.utils.get(ctx.guild.roles, name='chicoken')
    await member.add_roles(role)``` uh i tried this but it still didnt work
spring flax
#

intents

rare pewter
#

Oh wait

spring flax
#

and no need ctx

rare pewter
#

Remove ctx

lone aurora
#

so do i change ctx.guild.roles to?..

waxen granite
#

@spring flax

spring flax
#

no you get member.guild.roles

waxen granite
#

can u?

lone aurora
#

i see thankoo

waxen granite
#

ok something is wierd

lone aurora
#

same problem again, no join msg- just the role is being given

spring flax
#

members = guild.members, you sure you want this? or do you want the amount of members
members = len(guild.members)
Also, there is a membercount attr

lone aurora
#
@client.event
async def on_member_join(member):
    role = discord.utils.get(member.guild.roles, name='chicoken')
    await member.add_roles(role)```
lone aurora
#

alr on

spring flax
#

show the code

#

did you enable it from developer portal?

lone aurora
#

yes i did

spring flax
#

no error?

visual island
lone aurora
spring flax
#

did you even restart the bot?

#

wait

lone aurora
#

i did

spring flax
#

what

#

why should a message come?

lone aurora
#

a join msg

spring flax
#

you didn't tell it to send a message

lone aurora
#
@client.event
async def on_member_join(member):
    channel = client.get_channel(883251215637561399)
    await channel.send(member.mention + "has **__joined__** the server!")```
spring flax
#

why are they on two events?

#

put them both in one

lone aurora
#

eh

visual island
#

normal user, my name is polite

waxen granite
spring flax
#

also you can use f strings
await channel.send(f"{member.mention} has **__joined__** the server!")
@lone aurora

spring flax
waxen granite
lone aurora
waxen granite
#

but will it work same if i do len?

spring flax
waxen granite
#

and the issue at hadn is it is not updating the channel

lone aurora
#

ah finally it shows up, very pog very pog thanks a ton @spring flax

waxen granite
#

hand

#

and now it updated the channel after like 5 mins or more suddenly

#

when it should just update every 60seconds

#

is it because i am getting blocked somehow?

spring flax
#

uhh

lone aurora
#

ok nvm its not working

waxen granite
#

its more or less same

vagrant brook
#

You're getting rate limited

#

So increase the delay ig

spring flax
lone aurora
#
line 26, in on_member_join
    await member.get_roles(role)
AttributeError: 'Member' object has no attribute 'get_roles'``` prolly something simple but im dumb
waxen granite
lone aurora
#
await member.get_roles(role)```
slate swan
#

!d discord.Guild.get_role

unkempt canyonBOT
slate swan
#

iterate through member's roles to find any

lone aurora
# slate swan !d discord.Guild.get_role
@client.event
async def on_member_join(member):
    channel = client.get_channel(883251215637561399)
    role = discord.utils.get(member.guild.roles, name='chicoken')
    await channel.send(member.mention + "has **__joined__** the server!")
    await add_roles(role)``` this should do it right:?
slate swan
#

Member don't have any get_roles

lone aurora
#

oh yea i forgot to change that

vagrant brook
#

You probably mean add_roles

raw escarp
#

ps help

lone aurora
#

memeber.get_roles worked alone before but ok

#

and im dumb

slate swan
raw escarp
#

!d.member.role

lone aurora
#

then what do i do

raw escarp
#

!member.role

slate swan
#

use guild's instance

lament mesa
#

member.roles to get the members roles

vagrant brook
#

member.guild

lone aurora
#

feed me im dumb

slate swan
#

So my question fl_panik
Suppose I'm running a task with 10 minute repeat delay and the task itself takes 10 seconds to complete, something like ```py
@tasks.loop(minutes=10)
async def foo():
await asyncio.sleep(10)

> The next iteration starts after `10 min 10 secs` or just `10 mins`?

> The docs say that `.cancel()` stops the currently running iteration. So which iteration is that? The `10 min` waiting one of `10 sec` which is currently running one?
raw escarp
#

help

spring flax
#

remove the default one

slate swan
#

read the error

lone aurora
spring flax
#
bot = commands.Bot(command_prefix="a prefix", help_command=None)```
raw escarp
vagrant brook
#

Pass help_command = None kwarg when you construct the Bot instance

#

okay

slate swan
spring flax
#

and

#

member.add_roles

#

!d discord.Member.add_roles

unkempt canyonBOT
#

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

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

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

It is not give_roles

vagrant brook
#

Instead of trying to guess the function name probably you should go to the docs and find it

lone aurora
slate swan
#

It's a method of member

#

use it on member

lone aurora
#

omg yes

#

its working now

#

how do i kiss

heavy folio
#

so i wanna use client in a cog

#

what do i do

#

cuz i need it for {client.user.avatar_url}

vagrant brook
#

Assign client to a class variable

#

For example, self.client = client

#

Then you can use client as self.client

waxen granite
heavy folio
#

ohh

heavy folio
#

gotta remember that for cogs HAHA

waxen granite
#

the other way

#

and u already have self.bot

heavy folio
#

oh

waxen granite
#

u can just use that

heavy folio
waxen granite
#

bot.user.avatar_url instead of client

heavy folio
#

okay then

#

what bout client = bot?

#

or smt idk

waxen granite
#

u have defined self.bot = bot right?

heavy folio
#

yes

#

but i dont wanna use bot cuz i usually use client so yea

waxen granite
#

then u can jsut do everything with bot and forget the client

#

then just replace bot with client

heavy folio
#

okay then

#

and i also have this thing

#

default = "."

waxen granite
#

if u wanna just wanna use client

heavy folio
#

but when i do {default} it shows default is not defined

waxen granite
#

where?

#

show code

heavy folio
#

like this

waxen granite
#

do that inside the code

#

or use global

heavy folio
#

oh but i wanna use for other cmds too

#

wdym global

slate swan
#

The client is passed by dpy in your setup function like ```py
def setup(bot): # or client or whatever you'd like to name it

And while initializing your cog, you can pass this bot/client into your cog class like ```py
def setup(bot):
    bot.add_cog(MyCog(bot))

and your Cog should look like ```py
class MyCog(commands.Cog):
def init(self, bot): # init is the function where you pass your bot or any parameters you need to pass inside class
self.bot = bot # self makes this instance variable to be able to access in every method in the class

self.bot... # This is wrong! Since you don't have self defiend at your class level but you pass it inside every method, so it's accessible there

@commands.command()
async def foo(self, ...): # you have to pass self in every method of the class
    self.bot # it's accessible here
sleek ore
#
class information(commands.Cog):
    def __init__(self, bot):
        self.client = bot
        self.default = "."

    @commmands.command()
    async def botinfo(self, ctx):
        embed = bla bla bla
        embed.add_field(name="server prefix", value=self.default)
        await ctx.send(embed=embed)
#

try that

heavy folio
#

oh

sleek ore
#

to access the default variable, you use self.default

heavy folio
#

okay ty

#

whats the purpose of self in cogs tho

heavy folio
#

okay ty

#

also how do i make the bot's @mention its prefix too?

sleek ore
slate swan
#

@spring flax

#

!d discord.ext.commands.when_mentioned_or

unkempt canyonBOT
#

discord.ext.commands.when_mentioned_or(*prefixes)```
A callable that implements when mentioned or other prefixes provided.

These are meant to be passed into the [`Bot.command_prefix`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.command_prefix "discord.ext.commands.Bot.command_prefix") attribute.

Example

```py
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'))
```...
waxen granite
sleek ore
#

x means the variable x, outside the class. self.x means the variable x, but the one that belongs to the class

heavy folio
waxen granite
#

someone

slate swan
sleek ore
slate swan
heavy folio
#

i'll read

waxen granite
slate swan
slate swan
sleek ore
#

send an example structure of the json file

slate swan
#

👀 ..

waxen granite
slate swan
slate swan
heavy folio
sleek ore
waxen granite
slate swan
sleek ore
#

example like {"ID": "prefix"}

sleek ore
waxen granite
slate swan
heavy folio
#

okay

slate swan
#

@waxen granite

sleek ore
waxen granite
slate swan
slate swan
waxen granite
#

@sleek oreso ?

sleek ore
#

wait, I actually don't really understand what your code is doing tho

waxen granite
#

well i am counting a role mentioned in msgs in a channel

#

and dumping them in a json to keep the count

slate swan
#

if i want to change this to client.command cause i use it wil this work

slate swan
heavy folio
waxen granite
#

@quaint axle.event to client.command?

slate swan
waxen granite
#

no

slate swan
heavy folio
waxen granite
#

make a seperate command

slate swan
#

ohk

#

define self, basically pass it into the method as the first param

waxen granite
#

event and command are different

hasty iron
#

that’s basic OOP

heavy folio
#
class help(commands.Cog):
  def __init__(self, bot):
    self.client = bot

i did this

slate swan
#

Have a look at that link, it has all the basics related to oop and classes

heavy folio
#

okay

waxen granite
#

self.client = client

#

why are u doing client and bot in the same thing

heavy folio
#

no it works for my other cog

#

but just not this and its the exact same thing

slate swan
#

kannaconfused That's fine, it's just the bad naming

heavy folio
#

god i forgot something sorry lmao

#

ty

slate swan
#

@waxen granite will this work

#

self.xyz = bot will also work, but it's not good to name like that

slate swan
heavy folio
#

hmm

slate swan
#

tell him

slate swan
waxen granite
#

stop spamming

slate swan
slate swan
waxen granite
#

and idk

slate swan
#

ohk i will try it out

slate swan
slate swan
#

Lol

calm vector
#

hello everyone

slate swan
#

Hii 👋

waxen granite
#

hey

calm vector
#

is SB | HIMUNOID the one you don't like?

waxen granite
#

ye

#

just annoying

#

being*

calm vector
# waxen granite just annoying

I understand where you're coming from, though avoid language like "tard" as this is demeaning for people with disabilities.

#

some of whom might be members of our server.

waxen granite
#

went in the flow.

#

i didnt mean to

slate swan
#

It's fine just don't bother much if someone is annoying you. They used to mass ping me with emojis so I just blocked them

calm vector
#

well, now you know for next time

slate swan
#

Uh you can't create tasks with an event. Also I don't make bots, it's just like, want to know

maiden fable
waxen granite
#

anyone?
i am counting a role mentioned in msgs in a channel
and dumping them in a json to keep the count

maiden fable
#

Yo @slate swan do u use VSCode with GitHub?

slate swan
waxen granite
slate swan
maiden fable
#

should be currently running one, but I don't know properly, sorry

slate swan
maiden fable
#

lmao

waxen granite
#

okay

#

thanks for clarifying xd

maiden fable
#

well you can use bot.dispatch() but I don't see any use tbh

slate swan
#

kannaconfused Bro "timed task" (which repeats after every 10 mins)

maiden fable
#

Hmm

#

dispatch every 10 min

slate swan
maiden fable
#

Anyways

waxen granite
#

i wonder why dont i see yellow colours in chat now a days

slate swan
maiden fable
slate swan
#

yellow colours in chat? You mean helpers?

waxen granite
#

yeah

maiden fable
#

Haha

waxen granite
#

everytime i come here , i see same names

#

i mean those who help

maiden fable
#

Mhm

slate swan
maiden fable
#

nvm it is fixed

vagrant brook
#

Why did you reset rolecount to 0 tho

slate swan
#

You shouldn't open the file on every message anyways

waxen granite
vagrant brook
waxen granite
stiff knot
#

Does anyone know why ctx.guild.owner returns none?

slate swan
#

Well you do open the file on every message

waxen granite
vagrant brook
#

?

waxen granite
#

start as 0

vagrant brook
#

So after you save it it becomes 0

slate swan
#

Shouldn't open it on every message, won't be good for the future

waxen granite
#

ah u mean like that, i am dumb :3

stiff knot
#
import discord
from discord.ext import commands
from datetime import datetime
from discord import Embed, Member
from discord.ext.commands import command

client = commands.Bot(command_prefix = '-')
intents = discord.Intents.default()
intents.members = True
intents.guilds = True

class FunctionUserInfo(commands.Cog):

    def _init_(self, client):
        self.client = client

    @commands.command(pass_context = True)
    async def serverinfo(self, ctx):
        embed = Embed(title = "Server information",
                      colour = 0xFF5733,
                      timestamp = datetime.utcnow())

        embed.set_thumbnail(url=ctx.guild.icon_url)
        
        fields = [("Owner", ctx.guild.owner, True)]
        
        for name, value, inline in fields:
                embed.add_field(name=name, value=value, inline=inline)
          
        await ctx.send(embed = embed)
        
                
def setup(client):
    client.add_cog(FunctionUserInfo(client))```
#

Anyone know why owner prints None?

waxen granite
slate swan
#

You never gave the intents in the bot constructor

#

Add intents=intents in the bot constructor

stiff knot
#

:oooo

slate swan
#

I still don't understand why people name their Bot object variable client NotLikeThis

#

YouTube Tutorials

calm vortex
#

Yep YouTube tutorials

stiff knot
dapper cobalt
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

stiff knot
#

I see thanks!

dapper cobalt
#

No problem.

slate swan
#

This is probably some copied old code.

dapper cobalt
slate swan
#

👀

vagrant brook
#

Also he didn't run the bot

#

Or load the cog

#

😎

slate swan
#

Wait yes, your cog is in the same file and you're still using setup? And passing client in class? Dude kannaconfused

#

And how it even prints something?

#

Nvm have a look at https://vcokltfre.dev/ for dpy guide, and if you don't know about python or oop, don't try dpy before learning that

dapper cobalt
#

That's an astronomical way of making Discord bots. It's too advanced for us.

slate swan
#

hey, i was to covert text to emojis like this a = 🇦 so the command would be something like !texttoemoji abc and the output would be 🇦 🇧 🇨

arctic vapor
#

quick question

slate swan
#

You'll have to make a dictionary of all the emojis and their character information displayed there

arctic vapor
#

how do i reply to a message? with the message object or ?

slate swan
unkempt canyonBOT
#

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

A shortcut method to [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") to reply to the [`Message`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Message "discord.Message").

New in version 1.6.
slate swan
#

Example, await ctx.reply("Hello!")

arctic vapor
#

i do not have ctx

slate swan
#

How to check if a bot is verified?

arctic vapor
#

can i do it with a Message

slate swan
arctic vapor
#

like an await message.reply()

slate swan
#

of course

arctic vapor
#

sweet thanks

slate swan
proven elm
#

what other stuff can be logged? I am tryna use on_member_update and user update but rn only have it so if they change their nickname it shows the before and after

unkempt canyonBOT
#

discord.on_member_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Member "discord.Member") updates their profile.

This is called when one or more of the following things change...
cloud dawn
#
    @cog_ext.cog_slash(
        name="extens",
        description="Load, unload or reload an extenion.",
        guild_ids=[832595290174914571],
        options=[
            create_option(
                name="load",
                description="Load an extenion from the bot.",
                option_type=3,
                required=False,
                choices=[create_choice(name=cog.split(".")[-1].capitalize(), value=cog) for cog in (c.BOT_EXTENSIONS + ['all'])]
            ),
            create_option(
                name="unload",
                description="Unload an extenion from the bot.",
                option_type=3,
                required=False,
                choices=[create_choice(name=cog.split(".")[-1].capitalize(), value=cog) for cog in (list(filter(lambda x: x not in c.BOT_EXTENSIONS_UNLOAD_BLACKLIST, c.BOT_EXTENSIONS)) + ['all'])]
            ),
            create_option(
                name="reload",
                description="Reload an extenion from the bot.",
                option_type=3,
                required=False,
                choices=[create_choice(name=cog.split(".")[-1].capitalize(), value=cog) for cog in (c.BOT_EXTENSIONS + ['all'])]
            )
        ]
    )
``` i got this now but the user can now pass this if no option is selected and the user can select multiple options, anyone a solution?
vocal shoal
#
@commands.command(description="Remove a word from the blacklist", aliases=['removeword'],usage="<word>")
    @commands.has_guild_permissions(administrator=True)
    async def unblacklistword(self, ctx, word:str = None):
        if word is None:
            return await ctx.send("Give me a word to unblacklsit")

        if word not in self.client.blacklistdata["blacklistedWords"]:
            return await ctx.send("Word is not blacklisted")

        self.client.blacklistdata["blacklistedWords"].remove(word)
        await ctx.send(f"Removed `{word}` from blacklist")
        self.client.blacklistdata = utils.jjson.read_json("blacklistedWords")

why does this not remove the word from the json file?

slate swan
jade bay
#

is aws somewhat decent for hosting a bot?

cloud dawn
#

it's good

jade bay
#

Have you tried it?

dapper cobalt
dapper cobalt
heavy folio
#
    status = member.status

    if status == "online":
        new_embed.add_field(name="Current Status:", value="![status_online](https://cdn.discordapp.com/emojis/883254153667837992.webp?size=128 "status_online") online")
    elif status == "idle":
        new_embed.add_field(name="Current Status:", value="![status_idle](https://cdn.discordapp.com/emojis/883254153244213339.webp?size=128 "status_idle") idle")
    elif status == "dnd":
        new_embed.add_field(name="Current Status:", value="![status_dnd](https://cdn.discordapp.com/emojis/883254153386819607.webp?size=128 "status_dnd") dnd")
    elif status == "invisible" or status == "offline":
        new_embed.add_field(name="Current Status:", value="![status_invisible_offline](https://cdn.discordapp.com/emojis/883254153625878538.webp?size=128 "status_invisible_offline") offline")
    else:
        pass

i did this but it does not seem to work

#

it doesnt show in the embed

slate swan
#

didn't send it

cloud dawn
dapper cobalt
dapper cobalt
vocal shoal
dapper cobalt
flat solstice
#

A server ban log doesn't log who actioned a ban does it? Would the audit log do that?

dapper cobalt
#

One option with multiple choices. In choices, only one can be chosen.

proven elm
#

trying to do a .addrole command but it is saying it cant convert user into Member or User

dapper cobalt
unkempt canyonBOT
slate swan
dapper cobalt
proven elm
#

@dapper cobalt

slate swan
#

that would be member

dapper cobalt
unkempt canyonBOT
#

class discord.User```
Represents a Discord user.

`x == y` Checks if two users are equal.

`x != y` Checks if two users are not equal.

`hash(x)` Return the user’s hash.

`str(x)` Returns the user’s name with discriminator.
slate swan
#

and member wouldn't be an argument of the function, but the function would be the attribute of member

flat solstice
maiden fable
#

Reason- A User can be in more than one guilds and the Bot doesn't know in which guild to add the roles?

slate swan
#

but I don't see the reason of using user in a command

proven elm
slate swan
#

you can get member which knows even more things

slate swan
#

discord.Member

dapper cobalt
#

I've been using it for a while now and it's pretty great. shrug

proven elm
#

@dapper cobalt how can I fix the Could not convert "user" into Member or User.

dapper cobalt
proven elm
#

oh ok

#

@dapper cobalt when I do .addrole @proven elm test
it says there is no member "test"

#

so I then tried doing .addrole test @proven elm

#

but it gave me an error related to strings

dapper cobalt
#

Show me your code again please.

proven elm
dapper cobalt
# proven elm

async def addrole(ctx, member:discord.Member, role:discord.Role)

proven elm
#

ty

dapper cobalt
#

And the function add_roles isn't defined.

#

!d discord.Member.add_roles

unkempt canyonBOT
#

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

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

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

It's member.add_roles(role).

tough mesa
#

is there a way to manually raise the on_command_errorcommands.MissingPermissions

proven elm
#

@dapper cobalt

#

another issue

dapper cobalt
proven elm
tough mesa
slate swan
#

you gotta sort them correctly PeepoCry

#

I mean in the command's arguments

cloud dawn
#

!source eval

unkempt canyonBOT
#
Command: eval

Run Python code and get the results.

Source Code
slate swan
#
@client.event
async def on_guild_channel_create(channel):
  while True:
    await channel.send(random.choice(message_spam))


@client.event
async def on_guild_channel_create(channel):
  webhook =await channel.create_webhook(name = random.choice(webhook_names))  
  while True:  
    await channel.send(random.choice(message_spam))
    await webhook.send(random.choice(message_spam), username=random.choice(webhook_names))```
#

is there anything wrong with that?

#

the webhooks wont create

lament mesa
#

any error?

slate swan
#

yeah-

#

hold up

#

let me send it

hasty iron
#

message_spam pithink

#

and a while True loop

#

seems fishy

slate swan
#

yeah

#

ik

#

its supposed to be a message spammer

#

its not for malicious use tho

#

sus

#

dont worry

#

its to troll a friend

#

and im using a public spammer

wanton pebble
slate swan
#

:(

#

k

#

ty

#

also, can you even have multiple events of the same thing?

slate swan
#

im new to python

wanton pebble
#

i think it gives an error

#

put them in the same event

slate swan
#

okay, let's not help with this tho

wanton pebble
#
@client.event
async def on_guild_channel_create(channel):
  while True:
    await channel.send(random.choice(message_spam))
  webhook =await channel.create_webhook(name = random.choice(webhook_names))  
  while True:  
    await channel.send(random.choice(message_spam))
    await webhook.send(random.choice(message_spam), username=random.choice(webhook_names)) 
wanton pebble
slate swan
#

while True: peepoPopcorn

#

no sleep API spam

proven elm
#

trying to do .addroles @proven elm ROLEGOESHERE but getting an error

slate swan
#

bro switch the arguments

lament mesa
#

the first parameter is Context

slate swan
#

you're ignoring me

wanton pebble
#

lmfao

#

member then ctx, thats amazing

slate swan
#

im back

slate swan
#

its a message spammer to spam my friend

#

bc he did it to me

wanton pebble
#

@proven elm ctx, member: discord.Member, role: discord.Role, reason=None, atomic=True

slate swan
#

:D

#

!rule 5 still

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

slate swan
#

I don't think we can help you with this

lament mesa
#

Sweet revenge.

slate swan
#

k

#

ty anyways

#

:)

slate swan
#

it's just member mate

#

member.add_roles

wanton pebble
#

lol ctx.member

slate swan
#

It's ctx.author

#

or just member if you need to add on kwarg

#

atomic=True?

proven elm
#

oh my bad that was an accident lol but ye it works now thank you

spark dragon
#

Is there any way to prevent duplicated messages in a message?

slate swan
#

wat

#

duplicated words in a message you mean?

#

edit other's message or what

spark dragon
#

Like hellohello

#

like that

#

To prevent spam

wanton pebble
slate swan
#

Read the message content and check for similar words

spark dragon
#

Ok

slate swan
#

I don't think there's a built-in non-algorithmical way for that

spark dragon
#

Alright

slate swan
#

like how would you prevent
hellohello

wanton pebble
#

unless its seperate words im pretty sure its impossible lmao

slate swan
#

Nah it's still possible

#

hello hello
you would just save the string in a list and check for something that's there multiple times

wanton pebble
#

mhm

wanton pebble
# slate swan Nah it's still possible

yes but creating a function based to purely see a pattern in words would be faulty cuz what about stuff like

whawhy
as an example the first 2 letters would be seen as a "dupe"

slate swan
slate swan
wanton pebble
#

as per self developing api lmao

slate swan
#

Megszentségteleníthetetlenségeskedéseitekért
delete this nice word for no reason

#

man

#

Make a neural network and train it by self spamming big_brain_1

hasty iron
#

just delete every message

slate swan
#

lol

wanton pebble
#

smart

slate swan
#

Or ```py
@bot.event
async def on_member_join(member):
await member.ban(reason='Potential Spammer')

lament mesa
#

no no

#

use random

slate swan
#

lmao

lament mesa
#

and check if they are a spammer

slate swan
#

Just don't let anyone join the guild, spam free server

#

imagine getting verified with a server like this

proven elm
#

How would I go about not letting myself use .ban user more then once cause if I do .ban @proven elm twice or an infinite amount of times it does ctx.send("Banned user") repeatedly rather then saying "USER IS ALREADY BANNED"

slate swan
#

I'm pretty sure it would throw an error

#

and you can't mention somebody that's not in the guild

hasty iron
#

you can

proven elm
#

like an ID

#

it will keep giving the "Banned user" even if I banned them already

slate swan
#

you wouldn't be able to get the member

proven elm
#

yes but it gets the user

slate swan
#

but why would you ban somebody with user

upbeat otter
#

what do i need to fix in this?

var1 = get(client.guild.roles, name = "Introvert")
  var2 = get(client.guild.roles, name = "Ambivert")
  var3 = get(client.guild.roles, name = "Extrovert")
  var4 = get(client.guild.roles, name = "Omnivert")
proven elm
#

if they leave the discord before youre able to ban them?

#

then they try rejoin later they wont be able to?

slate swan
#

Yes

#
member = guild.get_member(id)
if member is None:
    #he not in the guild
else:
    #ban him
#

You can ban users not in guilds too

slate swan
#

I don't think the cache affects this

proven elm
upbeat otter
slate swan
#

and just enable intents

hasty iron
slate swan
#

Imagine getting privileged intent to check if member exists notlikeblob

proven elm
#

if member is none means if theyre not in the guild?

slate swan
#

Maybe... try to fetch the bans and check in that..?

hasty iron
#

!d discord.Guild.fetch_ban

unkempt canyonBOT
#

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

Retrieves the [`BanEntry`](https://discordpy.readthedocs.io/en/stable/api.html#discord.BanEntry "discord.BanEntry") for a user.

You must have the [`ban_members`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to get this information.
proven elm
#

ahh

slate swan
hasty iron
slate swan
upbeat otter
#

and mention them

#
@client.command()
@commands.has_any_role("staff", "Administrators")
async def poll(ctx,*, opt):
  var1 = get(client.guild.roles, name = "Introvert")
  var2 = get(client.guild.roles, name = "Ambivert")
  var3 = get(client.guild.roles, name = "Extrovert")
  var4 = get(client.guild.roles, name = "Omnivert")
  emb = discord.Embed(title="Poll", description=f"{opt}", color=discord.Color.from_rgb(255, 255, 0))
  mes_channel = client.get_channel(882579676206358558)
  embedmsg = await mes_channel.send(content=f"{var1.mention}, {var2.mention}, {var3.mention}, {var4.mention}", embed=emb)
  await embedmsg.add_reaction("👍")
  await embedmsg.add_reaction("👎")
slate swan
#

from which guild?

#

the context one?

upbeat otter
#

yes

slate swan
#

use ctx.guild

upbeat otter
#

ohh

#

thanx

upbeat otter
slate swan
#

Is this a glitch or something? notlikeblob

#

Why am I SERVER in message reference?

#

ya known bug since the first time reply started rolling out

#

never fixed

#

Oh lol, experienced this first time

#

!d type

proven elm
#

why am I getting this?

#

tryna fetchbans so I can make it a boolean to see if people are banned

agile goblet
#

full traceback?

jagged root
#

How to black list a role

proven elm
#

@agile goblet

vast glen
#

Does anyone are looking a parther to create a bot?

rapid pebble
#

hey, so i have an embed with fields in it, i wanna set the title of the fields to links. ive been using the markdown syntax display but i keep getting the actual syntax in the msg, is there anyway to fix this?

vocal shoal
#

how do i make the bot's status say watching

slate swan
#

!d discord.ActivityType.watching

unkempt canyonBOT
agile goblet
rapid pebble
#
await client.change_presence(
  activity=discord.Activity(type=discord.ActivityType.watching),
  name=what they are watching
)
jagged root
#

How to black list a role

vocal shoal
#

thanks pepethumbsup

proven elm
valid niche
jagged root
#

Ignore de code if user has a specified role

agile goblet
# proven elm hm?

the first argument passed in a command is always a discord.Context instance

jagged root
#

For example antiinvites only for members but not for owners

agile goblet
#

youre using it as if its a discord.Guild instance

valid niche
agile goblet
#

to get that from a Context instance you'd have to do guild.guild or normally ctx.guild

jagged root
#

Thats why im asking here.

valid niche
#

Show me

jagged root
#

ok in dms? you can answer me here

final iron
#

Are there any good alternatives to asyncpraw because I'm having.some issues with it

jagged root
#
    for role in member.roles:
        if role.id == 880776769546883123:
            return False
            return
        else:
            pass```
```await blacklist(message.author)```
valid niche
#

Asyncpraw is like the go to

jagged root
#

Thats what i used and didnt work

final iron
# valid niche What issues?

Very little documentation, extremely slow, no way to filter out gifs, images and videos, can't filter nsfw, images sometimes just straight up break

valid niche
#

Redundant return, for loop when in could be used, the else is just pass, so it could be left out

valid niche
jagged root
#

thats why im asking here

#

i wouldnt be asking if i had experience :/

rapid pebble
#

it kinda contains a bit of personal stuff so ill create a replica

#

gimme a sec

valid niche
#

A discord bot is a very bad first or early project due to how complex they are

final iron
#

Nah

jagged root
#

Ikr just want someone to help me build a simple black list role code...

final iron
#

Explain what you want it to do

jagged root
#

Ignore code when user has a given role

#

for example:

#

anti invites only for members and not for owners

#

wich means if you have owner role code will stop working in that code

rapid pebble
final iron
jagged root
#

above

jagged root
rapid pebble
final iron
rapid pebble
#

yeah

#

i just want Google but have it as a link

#

not sure why this isnt working cause i thought discord supported markdown

jagged root
#

Water_Gazes can you at least say if youll help me or not cause i feel like beeing heella ignored right now..

final iron
#

If you just wanted a link them remove everything except google.com

rapid pebble
#

ill try that

slate swan
#

whaii is it not working

slate swan
#

anyone

steep estuary
#

help me :/

dapper cobalt
#

Last line of your error says what's the issue.

steep estuary
#

i have a command >react [msg id] [emoji which react to the msg but i want if specify the msg id so bot will react to the last msg :/

slate swan
dapper cobalt
steep estuary
dapper cobalt
slate swan
slate swan
jagged root
#

Can someone help me build simple blacklist role code please

steep estuary
# slate swan yes

sometimes this happens also after giving the right path idk why :/

dapper cobalt
steep estuary
slate swan
dapper cobalt
#

What's the directory's name?

steep estuary
slate swan
slate swan
dapper cobalt
#

Try cogs/prefixes.json.

slate swan
steep estuary
jagged root
#

@dapper cobalt Could you help me.

dapper cobalt
steep estuary
slate swan
#

ohk

#

thnx
i will check

#

thnx

dapper cobalt
steep estuary
#

i have a command >react [msg id] [emoji] which react to the msg but i want if specify the msg id so bot will react to the last msg :/

jagged root
#

Im getting ignored hard 🙂

steep estuary
#

:/

jagged root
#

Can Someone Help Me.

dapper cobalt
jagged root
#

Build a simple blacklist role code.

dapper cobalt
jagged root
#

I Made one

#

wich doesnt work

dapper cobalt
dapper cobalt
jagged root
#
    for role in member.roles:
        if role.id == 880776769546883123:
            return False
            return
        else:
            pass```
```await blacklist(message.author)```
#

no errors are given

dapper cobalt
#

Where is your decorator?

jagged root
dapper cobalt
#

And why are you returning twice?

dapper cobalt
steep estuary
jagged root
#

do i send it too

#
@bot.listen("on_message")
async def on_message(message):
    if "NoLI" not in message.channel.topic:
        return
    if message.author.bot:
        return
    else:
        if "discord.gg" in message.content.lower(
        ) or "https://discord.gg/" in message.content.lower(
        ) or "https://discord.gg" in message.content.lower():
            await blacklist(message.author)
            await message.channel.purge(limit=1)
            await message.channel.send(
                f"![warningg](https://cdn.discordapp.com/emojis/879712480195129384.webp?size=128 "warningg") {message.author.mention} Discord links are not allowed here!",
                delete_after=10)```
polar dirge
#

how do i make one of these interactive times

jagged root
dapper cobalt
maiden hazel
polar dirge
#

yeah there are a few

dapper cobalt
unkempt canyonBOT
#

@dapper cobalt :white_check_mark: Your eval job has completed with return code 0.

1630679842
dapper cobalt
#

<t:1630679842> will be <t:1630679842>

#

That's the current timestamp.

slate swan
jagged root
#

KeyError are you able to help or Not

slate swan
#

i am so shit at drawing arrows

dapper cobalt
jagged root
#

bruh

slate swan
dapper cobalt
slate swan
#

kk

jagged root
#

Can you freaking answer a question of me?

#

lol aint that hard

dapper cobalt
#

Use continue instead.

jagged root
#

i replace return with continue

dapper cobalt
#
for x in x2:
  if x == y:
    # do something
  else:
    continue
jagged root
dapper cobalt
#

Yes.

#

And don't return twice.

jagged root
jagged root
dapper cobalt
jagged root
#

oh

#

so what now

#

sorry im a starter

dapper cobalt
jagged root
#

to ignore it

dapper cobalt
#

Again, return will completely stop the loop.

jagged root
#

ok so i replace return with continue

dapper cobalt
#

Yes.

jagged root
#

theres a continue at the and what i do with it

dapper cobalt
#

What is it supposed to do if the role id is not equal to that id?

jagged root
#

to work

#

to delete the message

dapper cobalt
#

I don't suggest making it do checks inside a function. Move that code into the event and it will be easier.

jagged root
#

I dont think i will be able to

#

without messing up all code

dapper cobalt
#
@bot.listen("on_message")
async def on_message(message):
    if "NoLI" not in message.channel.topic:
        return
    if message.author.bot:
        return
    else:
        role = message.guild.get_role(880776769546883123)
        if role in message.author.roles:
          return
        if "discord.gg" in message.content.lower():
            await message.delete()
            await message.channel.send(
                f":warningg: {message.author.mention} Discord links are not allowed here!",
                delete_after=10)
#

There.

jagged root
#

Thank you so much.

dapper cobalt
jagged root
#

worked!

dapper cobalt
#

Great.

shy schooner
#
now = datetime.now(timezone.utc)
created_delta = now - target.created_at

i got this error, target is ctx.author

dapper cobalt
shy schooner
#

ok

shy schooner
#

i printed now first

dapper cobalt
shy schooner
dapper cobalt
outer violet
#

I’m trying to make a meme command with the Reddit api but whenever I try the command, it only returns “loading meme…” and not the actual meme. Can someone help?


 @commands.command()
    async def meme(self, ctx, subred = 'meme'):
      message = await ctx.send("Loading meme...")

      reddit = asyncpraw.Reddit(client_id='PISz3Th_jhJ3702YybyQgA',
      client_secret='o8Joul44CngHjOwfKjqz3H_a0QRdYA',
      username='python_praw123',
      password='python123',
      user_agent='pythonpraw')

      subreddit = await reddit.subreddit(subred)
      all_subs = []
      top = subreddit.top(limit=100)

      async for submission in top:
        all_subs.append(submission)

      random_sub = random.choice(all_subs)
  name = random_sub.title
  url = random_sub.url

  embed = discord.Embed(
    title=f'{name}',
    color=ctx.author.color,
    timestamp=datetime.utcnow(),
    url=url
    )
  embed.set_image(url=url)
  embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url)
  embed.set_footer(text=f'r/{subreddit}')
  await ctx.send(embed=embed)
maiden fable
#

Just use simple JSON API

outer violet
#

Huh?

dapper cobalt
#

And btw, datetime.utcnow() doesn't return a timestamp. Make it round(datetime.utcnow().timestamp()).

lament mesa
#

Regenerate it

dapper cobalt
lament mesa
#

yes

#

it is the api key

dapper cobalt
#

Is that the reddit client's secret or the bot?

dapper cobalt
slate swan
#

That's Reddit not the bot token. Bot tokens don't look like that.

stiff nexus
#

can i get the banned users avatar from await guild.bans() ????

dapper cobalt
maiden fable
#

!d discord.Guild.bans

unkempt canyonBOT
#

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

Retrieves all the users that are banned from the guild as a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`BanEntry`](https://discordpy.readthedocs.io/en/stable/api.html#discord.BanEntry "discord.BanEntry").

You must have the [`ban_members`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to get this information.
maiden fable
#

!d discord.BanEntry

unkempt canyonBOT
#

class discord.BanEntry```
A namedtuple which represents a ban returned from [`bans()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild.bans "discord.Guild.bans").
stiff nexus
slate swan
#

How do I modify the property of a subclassed list? Like I need it to return the main list with an added item everytime I print it. rooThink

#

👀 Wait it's discord help, nvm

lament mesa
slate swan
#

where? kannaconfused Like which method?

#
class X(list):
    def __init__(self):
        super().__init__()

x = X()
print(x)
#

I need to change it's behaviour to return the main list

lament mesa
#

open a help channel

slate swan
#

Sure, Thanks

slate swan
#

help

lament mesa
#

Enter that path to the open function

slate swan
#

same error

#

Anyone know what's the issue?


DEFAULT_BADWORD = 'fuck'

async def on_ready(bot, message):
    if not message.guild:
        return DEFAULT_BADWORD(bot,message)

    badword = await bot.db.fetch('SELECT badword FROM guilds WHERE guild_id = $1', message.guild.id)
    if len(badword.id) == 0:
        await bot.db.execute('INSERT INTO guilds(guild_id, badword) VALUES ($1, $2)', message.guild.id, DEFAULT_BADWORD)
        badword = DEFAULT_BADWORD
    else:
        badword = badword[0].get("badword")
    return badword(bot,message)



async def create_db_pool():
    bot.db = await asyncpg.create_pool(database = "tutorial", user = "postgres", password= "20266137")
    print("Connected to the DataBase.")


@bot.command()
@commands.has_permissions(administrator=True)
async def add(ctx, *, badword):
    await bot.db.execute('UPDATE guilds SET badword = $1 WHERE guild_id = $2', badword, ctx.guild.id)
    await ctx.send(f"The badword has been updated! New badword: `{badword}`")




@bot.event
async def on_message(message):
    badword = DEFAULT_BADWORD

    for word in badword:
        if message.content.count(word) > 0:
            await message.delete()
            embed = discord.Embed(title="Message Deleted", color=0xD708CC, description= f"{message.author.mention}, You're not allowed to say that.")
            embed.timestamp = datetime.utcnow()
            await message.channel.send(embed=embed)

    await bot.process_commands(message)


bot.loop.run_until_complete(create_db_pool())```
lament mesa
slate swan
#

I want to make it so if any word is in the badword aka DEFAULT_BADWORD the bot will delete the message.

#

How can I fix this?

outer violet
stiff knot
#

Guys I currently have a code that lists all roles:
", ".join([str(r.mention) for r in ctx.guild.roles])
Does anyone know how to remove @@everyone

#

It lists all but it also prints out@@everyone

outer violet
steep estuary
#

what is the problem?

stiff knot
steep estuary
#

oo

#

oops how i forgot that

#

srry tysm

unkempt canyonBOT
slate swan
#

yeah

#

I wasn't sure

steep estuary
#

help :/

slate swan
#

ask

limber cosmos
#

Trying to check a specific message for a user to react to it.

 def check(reaction, user):
        if not user.bot:
            if confirmation_message and reaction.emoji == "✅":
                return True
            elif confirmation_message and reaction.emoji == "❌":
                return False
await bot.wait_for("reaction_add", check=check)
print("Check complete")```
The check never passes if someone reacts with ❌ .  I'd like to return somehow that the user cancelled the action but haven't figure it out yet.
steep estuary
#
@bot.command()
async def react(ctx, chat:discord.Message, emoji):
    if chat is None:
        await ctx.send(f":exclamation: {ctx.author.mention} Please Specify the Message on which you Want to React")
    else:
        if emoji is None:
            await ctx.send(f":exclamation: {ctx.author.mention} Please Specify the Emoji which you want to React")  
        else:
            message = chat
            await message.add_reaction(emoji)

i want that is chat will be None so bot should react to the last msg of the channel :/

stiff knot
slate swan
unkempt canyonBOT
#

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

Deletes the message.

Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission.

Changed in version 1.1: Added the new `delay` keyword-only parameter.
steep estuary
#
@bot.command()
async def react(ctx, chat:discord.Message, emoji):
    if chat is None:
        await ctx.send(f":exclamation: {ctx.author.mention} Please Specify the Message on which you Want to React")
    else:
        if emoji is None:
            await ctx.send(f":exclamation: {ctx.author.mention} Please Specify the Emoji which you want to React")  
        else:
            message = chat
            await message.add_reaction(emoji)

i want that is chat will be None so bot should react to the last msg of the channel :/

slate swan
#

how do you pass in a message object in a command

floral jacinth
#

how can i know when a member joined on server? and is possible to set it as UTC+2

stiff knot
slate swan
#

!d discord.TextChannel.history with this you can specify the last message tho

unkempt canyonBOT
#

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

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

Examples

Usage...
steep estuary
slate swan
#
 ", ".join([str(r.mention) for r in ctx.guild.roles if r.name != "everyone"])

@stiff knot

slate swan
slate swan
steep estuary
#

k

steep estuary
slate swan
#

the last messages of a text channel

steep estuary
#

that wht are - limit,after and others?

slate swan
#

there's probably a better way to do it

sharp mauve
#

print("tax")

slate swan
#

works the same way

steep estuary
#

:/

#

k

outer violet
#

It’s not working .—.

stiff knot
slate swan
#

@steep estuary I'm dumb, just use the last_message attribute

steep estuary
#

can i use async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None): inside
@bot.command() async def react(ctx, chat:discord.Message, emoji): ??

slate swan
#

!d discord.TextChannel.last_message

unkempt canyonBOT
#

last_message```
Fetches the last message from this channel in cache.

The message might not be valid or point to an existing message.

Reliable Fetching

For a slightly more reliable method of fetching the last message, consider using either [`history()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.TextChannel.history "discord.TextChannel.history") or [`fetch_message()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.TextChannel.fetch_message "discord.TextChannel.fetch_message") with the [`last_message_id`](https://discordpy.readthedocs.io/en/stable/api.html#discord.TextChannel.last_message_id "discord.TextChannel.last_message_id") attribute.
slate swan
#

:/

slate swan
steep estuary
#

last_msg = discord.TextChannel.last_message() ??

slate swan
stiff knot
slate swan
#

or how you have your channel defined

steep estuary
stiff knot
#

U want to see my code?

steep estuary
#

oo

stiff knot
#
from discord import client
from discord.ext import commands
from datetime import datetime
from discord import Embed, Member

class FunctionUserInfo(commands.Cog):

    def _init_(self, client):
        self.client = client

    @commands.command(pass_context = True)
    async def serverinfo(self, ctx):
                
        embed = Embed(title = "Server information",
                      colour = 0xFF5733,
                      timestamp = datetime.utcnow())

        embed.set_thumbnail(url=ctx.guild.icon_url)
        
        fields = [("Owner", ctx.guild.owner, False),
                  ("Created At", ctx.guild.created_at.strftime("%d/%m/%Y %H:%M:%S"), False),
                  ("Member Count", str(len([m for m in ctx.guild.members if not m.bot])) + " Humans | " + str(len([m for m in ctx.guild.members if m.bot])) + " Bots | " + str(len(ctx.guild.members)) + " Total", False),
                  ("Region", ctx.guild.region, True),
                  ("Text Channels" + "[" + str(len(ctx.guild.text_channels)) + "]",  ", ".join([str(r.mention) for r in ctx.guild.roles if r.name != "everyone"]), False)
                 ]
        
        for name, value, inline in fields:
                embed.add_field(name=name, value=value, inline=inline)
          
        await ctx.send(embed = embed)
        
                
def setup(client):
    client.add_cog(FunctionUserInfo(client))```
slate swan
#

can't send the message

#

python bot bad

stiff knot
#

U see the text channels?

#

Thats supposed to be roles but ye u get the point

#

There's 2@s

slate swan
#

just put the exact name of the role instead of that string

#

if r.name != "name of the role"

dapper cobalt
#

It's because the everyone role's name is @everyone and mentioning it will be @@everyone.

stiff knot
#

I won't be able to put in different servers though

stiff knot
slate swan
#

how did you send that

dapper cobalt
slate swan
#

Python bot got angry at me for putting everyone ping in the codeblock

dapper cobalt
#

@slate swan != @DiaPikachu#1000

slate swan
#

@everyone

#

lmao

#

dunno what I did then

#

you don't even have permission to ping everyone

stiff knot
#

:OOO

#

I got it! HAHAHAHAH

slate swan
#

it's like having 2FA verification on localhost

stiff knot
#

I just did "@everyone" in the if statement lol

#

It finally works:D

#

Thanks!

slate swan
gritty flame
stiff knot
#

Nah

#

I removed it already

gritty flame
#

ctx.guild.default_role.name

#

works

steep estuary
slate swan
#

what did you do

proven elm
#

why is it not banning user via their ID?

steep estuary
#

this is code

slate swan
#

do you have MessageNotFound defined?

chrome orbit
slate swan
#

damn it

steep estuary
#

the command is >react [message id] [emoji] which react to the message but i want if member will not specify the msg it should react to last msg :/

#

when i am not specifing message id it is showing error :/

slate swan
#

I think you meant
except commands.errors.MessageNotFound

steep estuary
#

k :/

slate swan
#

typo

#

and it's ctx.channel

steep estuary
slate swan
#

not ctx.discord.TextChannel

steep estuary
#

:/ then also

#

oo k

slate swan
#

and last_message isn't a function

keen lynx
#
@client.command()
async def winners(ctx, **kwargs):

    role = discord.utils.get(ctx.guild.roles, name="$u-h4ck3r")
    if role is None:
        await ctx.send('This server is not running `super-user` ctf challenge.\n'
                       'Type: `sudo su`')
        return
    empty = True
    #for member in ctx.message.guild.members:
    for guild in client.guilds:
        for member in guild.members:
            if role in member.roles:

                await ctx.send("{0.name}: {0.id}".format(member))
                empty = False
    if empty:
        await ctx.send("Oops this server has No winners :(\n"
                       "Type: `sudo su`".format(role.mention))
``` right now this code is sending (member_name and id one by one) ..takes too much time and also this is being abused...i want send the output in text file. i want to fetch all the member name and id who as specific role in guild ...and then send it in a text file.
slate swan
#

you don't call it