#discord-bots
1 messages · Page 701 of 1
await ctx.send("message")
await ctx.send(embed=your_embed)
along with the embed object
yep been a while since i did discord.py bot development so my knowledge is quite rusty haha
THANK U
i find myself referring back to the docs for menial things i knew off the top of my head before xD
What do you do now?
been getting out of my comfort zone with javascript bots a bit, mostly javascript frontend frameworks though
That's nice
yep though i've done discord.py for almost 2 years before so i keep coming back here to help haha
I mostly do dpy but i think i hit a block i havent learned as much as i did and i want to do complicated stuff but idk what mostly trying to learn about dbs but i havent gone the excitement/passion for it
yeah i feel you i used to get like that too, i take a break and i come back a few weeks later fresh with ideas, always seemed to help me
2 years wow ive only done 9months lol
Ill take that advice thanks
yeah i think i started early covid last year ish?
can't believe that was almost 2 years ago haha
I feel you
Ive grown allot of knowledge about oop and asynchronous programming and with dpy i still remember 9 months ago i didnt even knew what was a coro
Or a kwarg
that's one of the best feelings, looking back and remembering how much you've grown as a developer
Yeah
maybe in another year you'll look back at yourself right now and think the same thing
interactive help channels are probably one of the best ways to grow and learn new things, yeah
And ill always see people like andy,kayle,robin,hunter,infernum and much others that really had allot of knowledge and it was intimidating but it gaved me passion to be like them and now ive grown in knowledge about the topic and i mostly help others here with you guys but i still like seeing you guys talk about topics i have 0 knowledge about it really makes me excited to see that i can learn more
Yeah very true
appreciate it man, you can be one of us too haha
I mean i wish lol i try my best to be like you guys but you guys always blow my mind 😅
Mostly learn python because of my future and because i love programming by itself but i always come here because theres allot of knowledgeable people here but helping others and making there day is good to always makes me happy
for sure, i gotta say helping people and interacting with others here is always the better part of my day :P
i appreciate everyone who helps others :)
That makes it much easier for us to give help, though not everyone goes by that philosophy D:
100%
Others dont say thank you, but does who appreciate what we do always the ones that put a smile on my face tbh
I mean i try
@sick birch this is probably ot but i enjoyed the talk we had and merry Christmas
Sorry for the ping.
You too! Unfortunately it's almost 1 am for me and i'm off to bed, good day/night wherever you are :D
Its 2am almost 3 here,Good night sleep well :)
is there any way to have aliases for commands
like if i have ;image but also wanna have it be ;img
Yes
@bot.command(aliases=["",""])
ty
Yw
Can anybody explain what this does i cant quite rap it around my head
class MyButton(disnake.ui.View):
def __init__(self, author: disnake.Member):
self.author = author
super().__init__()
# your code
@bot.slash_command()
async def button(inter: disnake.AppCmdInt):
view = MyButton(inter.author)
await inter.response.send_message("hi", view=view)
mostly how
inter.author
Works with the class
Other stuff i get it
how do i get the "intro" of the bot on the first page and the commands and their descriptions on the second? im using discord-ext-menus https://mystb.in/PtyHoldingGamma.python
@bot.command()
@commands.has_permissions(ban_members=True)
async def mute(ctx,member: disnake.Member,time=None,*,reason=None):
if reason == None:
reason = 'Quiet! '
await member.timeout(duration=time,reason=reason)
await ctx.channel.send(f'member has been muted')```
Hi ! is this timeout code correct?
Looks good to me but type hint time as a float
cuz its showing this error :-
discord.ext.commands.errors.BadArgument: Converting to "Member" failed for parameter "member".```
So it would be
time:float = None
ok i'll make the change
thx
but umm ..
its still showing this error
Could you show the message that you sent the command with?
Cause it’s not converting the member
Weird
Anyone?
Huh I don’t see anything wrong
same
Thats weird i dont see an issue
oh alr
im gonna try to install a different one
lets see if that works
anyone thanks a lot everyone for your help
Yeah its up to date
Maybe cause mention has spaces in it so it separates it?
Try quotes around mentions. If not that then idk
could be ill try to changethe nick
Is the actually content shown as <@id>?
The member arg has been type hinted to a member obj so it would be a separate argument that takes a @ or a member id
Wait really?
Ic
Ig it wasnt cuz of spaces
I just changed my disnake to discord-disnake and it worked
I added back the space and its still working
Still confused
Yeah probably wasn’t cause spaces because I think a ping is really only <@id> (one word) even when the name is many words
Its too complicated for me
yea
what dont you get?
Well how im viewing (inter.author)
A interaction and then?
helo
ok, so why my SBtext says no module eventhough i aready pip install that module (in different file folder tho) and when i try pip install that module again, CMD says that it's already satisfied
what
Yeah im having a stroke as well
just tell me what you dont understand about it
inter.author is the interaction author
is that what you're asking
def __init__(self, author: disnake.Member):
self.author = author
super().__init__()
And
view = MyButton(inter.author)
Just that
How do i know that?
still don't understand wym
^^
Just what this does
view = MyButton(inter.author)
passing the interaction author ig?
Yes
ok, where to ask this
Something like that
yeah
How does it pass the interaction author?
How does it pass a member?
@slate swan read your class
Sorry its 3am im having a brainfart
you passed in a parameter next to self
u have author : disnake.Member
that allows you to pass in arguments to the class
what give more context
...
Okay so inter is interaction and author is a member obj so how does
MyButton(inter.author)
Work
im viewing a class and what else is exactly what im not getting
what do you mean by work? your passing a member object which is the author of the slash command to the class
Nah nvm i just had a massive brain fart but i just read some docs about classes and now i understand my bad for the inconvenience
hm ok
Ah i get it now thank you
👌
I think all of my questions was mainly how inter gets the interaction author
Because yes author is a member obj but how does inter get the interaction author if interaction is typehinted as a interaction?
Are you talkin about application commands?
Correct
wow finnaly someone understand
I'm attempting to add a message that sends when a new user joins. I have been able to get the message to send in a embed and now I would like for the bot to grab the pfp of the new member and add it to the embed. ```PY
@client.event
async def on_member_join(member):
channel = client.get_channel(854988021711896586)
await channel.send(
embed=discord.Embed(
colour = (discord.Colour.green()),
Title = "welcome",
description = f'Welcome {member.mention}, enjoy your stay!',)
)```
Here is the code
So usually with a bot, when someone cast a command, the context of the command is the message that the user sent, instead, with an application bot, the context cannot be the message of the user cuz it will interact directly with the bot so instead that interaction is the context of the command, from that interaction you can retrieve the application command of the user
Ah makes way more sense so in this case interaction is just the author of the interaction as ctx is the context of the msg
no no the ApplicationInteraction can retrieve all the data of the command, i will send you the part of code where the data are retrieved in disnake
!d discord.Embed.set_thumbnail
set_thumbnail(*, url)```
Sets the thumbnail for the embed content.
This function returns the class instance to allow for fluent-style chaining.
Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the thumbnail.
!d discord.Embed.set_image
set_image(*, url)```
Sets the image for the embed content.
This function returns the class instance to allow for fluent-style chaining.
Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the image.
I see
def __init__(
self,
*,
data: ApplicationCommandInteractionDataPayload,
state: ConnectionState,
guild: Optional[Guild],
):
self.id: int = int(data["id"])
self.name: str = data["name"]
self.type: ApplicationCommandType = try_enum(ApplicationCommandType, data.get("type"))
self.resolved = ApplicationCommandInteractionDataResolved(
data=data.get("resolved", {}), state=state, guild=guild
)
target_id = data.get("target_id")
self.target_id: Optional[int] = None if target_id is None else int(target_id)
self.target: Optional[Union[User, Member, Message]] = self.resolved.get(self.target_id) # type: ignore
self.options: List[ApplicationCommandInteractionDataOption] = [
ApplicationCommandInteractionDataOption(data=d, resolved=self.resolved)
for d in data.get("options", [])
]
This is the init function of ApplicationCommandInteractionData in disnake
use the, member.avatar_url or member.avatar.url to retrieve the pfp
Alright i get it now thank you
Thanks, however when I implement that it interferes with the two lines of code under it
keep_alive()
client.run(os.getenv("TOKEN"))```
invalid syntax
pyflakes
keep_alive()
screenshot ;-;
you are probably getting an error due to a parantheses
I am Im just confused on where to place it
huh
keep_alive() is nothing... it is not a function and is not a builtin python function
I think I also forgot to add embed.set_image
I know that but its crucial to keeping the bot up
And if I delete it it just brings up the same error with client.run\
its not like that
@commands.command()
async def daftar(self, ctx):
await ctx.send(f"masukkan username")
def check1(msg):
return msg.author == ctx.author and msg.channel == ctx.channel
user_choice_username = (await self.bot.wait_for('message', check=check1)).content
await ctx.send(f"masukkan game id")
def check2(msg):
return msg.author == ctx.author and msg.channel == ctx.channel
user_choice_game_id = (await self.bot.wait_for('message', check=check2)).content
await ctx.send(f"masukkan role")
def check3(msg):
return msg.author == ctx.author and msg.channel == ctx.channel
user_choice_role = (await self.bot.wait_for('message', check=check3)).content
await ctx.send(f"masukkan gambar")
def check4(msg):
return msg.author == ctx.author and msg.channel == ctx.channel
user_choice_url = await self.bot.wait_for('message', check=check4)
if user_choice_url.content.attachments:
file = user_choice_url.attachments
print(file.url)```
how to check if user input attachment or no?
Yeah sorry I normally do discord.js lol
embed = discord.Embed(title="smh", desc.......)
embed.set_thumbnail(url=member.avatar_url)
``` like this
What have you wrote in the TOKEN field in your env? (Yeah don't send it but if you saved it as a string it will return an error xD)
Traceback (most recent call last):
File "d:\dittttbotbeta\.env\lib\site-packages\discord\ext\commands\core.py", line 88, in wrapped
ret = await coro(*args, **kwargs)
File "d:\dittttbotbeta\data\mlbb.py", line 63, in daftar
if user_choice_url.content.attachments:
AttributeError: 'str' object has no attribute 'attachments'```
just if user_choice_url.attachments:
I have the discord bot token lol
Ah my bad I did embed.set_image(member.avatar_url)
of course, i mean, have you addedd the "" before write the token?
okey thanks
Yes its right there
add a url parameter
You have to remove them lol
the enviromenth variables are saved like in a file, the os.getenv function read from that file so it will convert atuomatically that to string
essentially you are send your token like "your_token"
replit removed env files a long time ago
What like the "" is not in the env parameter for my token
The token is not the problem
If it break at .run method then the token is the problem D_D
I said that env files dont exist on replit anymore ;-; what else
Bruh it works perfectly fine the only problem is me adding the img
and where he is readin the token then? lol
The same issue arises with that
the error is?
hmm
Actually one second I think I was missing a additional parenthesis sorry
;-;
nvm
thats what I said first
why comma atlast in like 56?
Otherwise embed isnt recognized
no?
;-; make an embed outside the send method
Also why is it inside the send
It’s not suppose to be inside
Should it be like await channel.send(): and then the code?
no, make the embed outside the send method
Ok
It is a good use to first create the embed and then send it
good practice
essentially there you are creating an embed and then call that embed but it is not created yet lol
Ah lol
So what should I put inside the send() because other wise it creates errors
The embed is now above the send
It worked before idk how then its just the image
the send method takes in an embed kwarg so, .send(embed=embed)
^
!d discord.TextChannel.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
should be like this:
embed = Embed(title="abc", description="abc", colour=(255,255,255)
embed.set_thumbnail(url=ctx.author.image_url)
await ctx.send(embed=embed)
dont spoonfeed
lol we were confusing him bro
Already got it working now
bro
Thanks for the help
we have teached him enough about embeds xD
bris
..........
@upbeat otter My apologizes for pinging you directly but is there a way to position the picture in the embed? currently it is right aligned but I'm trying to get it center aligned on the next line
@steady phoenix u can't align pics

💀 Bruh on discord.js it would automatically put the image left aligned on the next line but its right aligned on the same line
Ok
Then use djs
how do i make a pin command where if i send the command on a replied message it pins it?
!d discord.Message.pin
await pin(*, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Pins the message.
You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to do this in a non-private channel context.
alr
is there a way to check if a user is present in a guild?
I have the user's id and the guild's id
you could check if the member is in the guild discord.Guild.members returns a list of member objects
get_guild(id, /)```
Returns a guild with the given ID.
ok
iterate through what
is it possible to get disnake on repl
It is
oh
It came just a while ago when timeout arrived
came along with timeout
and no i checked it on the api reference of the rewrite i use its there
Ofc
😳 imagine libraries forcing users to use python 3.9+ , rip replit users
Is there any documentation from discord of how to implement your bot into your website? Iike yk having a website displaying bot's guild conter and such
They usin’ 0.0 lmao
from discord no.
But you can have help on this website https://replit.com/talk/learn/Discordpy-Discord-Bot-Web-Dashboard-Tutorial/131455
everything on pypi is available on replit
Alright thanks
There is a check which tells me if the user who cast a command is the bot owner? or I have to check it manually?
you can check for the authors id ig
if <ctx>.author.id == <client>.owner.id
Maybe?
you can use is_owner check
!d discord.ext.commands.is_owner
@discord.ext.commands.is_owner()```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that checks if the person invoking this command is the owner of the bot.
This is powered by [`Bot.is_owner()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.is_owner "discord.ext.commands.Bot.is_owner").
This check raises a special exception, [`NotOwner`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NotOwner "discord.ext.commands.NotOwner") that is derived from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
thx
Anyone good with cogs
what
why?
My discord bot is gonna be quite lengthy and gonna need a fair amount of scripts 😂
why not make it yourself though
@client.event
async def on_raw_reaction_add(payload):
message_id = payload.message_id
if message == 923516305322176592 :
guild_id = payload.guild_id
guild = discord.utils.find(lambda g : g.id == guild_id, client.guilds)
if payload.emoji.name == 'boy':
role = discord.utils.get(guild.roles, name='boy')
elif payload.emoji.name == 'girl':
role = discord.utils.get(guild.roles, name='girl')
else:
role = discord.utils.get(guild.roles, name=payload.emoji.name)
if role is not None:
member = discord.utils.find(lambda m : m.id == payload.user_id, guild.members)
if member is not None:
await member.add_roles(role)
print("added")
else:
print("Member not found")
else:
print("Role not found")```
why is this not giving roles? what am I doing wrong ?
I am creating an advanced write command, that is, when the user writes "!write everyone" the bot does not send the message and gives a reply.
I tried to do this, there are no errors, but it doesn't work anyway
code:
async def write (ctx, *, arg, content, allowed_mentions):
await ctx.send (arg)
allow_mentions = discord.AllowedMentions(everyone = False)
await ctx.send(content, allow_mentions = allowed_mentions)```
What's the error
no error, no print , no nothing
its allowed_mentions not allow_mentions in the send method
you can only have one argument after consume operator
and
I am making it my self I’m just having issues?
ask away then
thats it, put the other arguments before consuming rest
You'd need to login with your bot on the website's back-end. I do that with my bot's website.
isnt this what discord-ext-ipc is for
I need to make it so my web scraping script is on a separate file that my bot can read from I will grab an example in a second just eating rn
i made a meme command and used reddit praw for it
it works but it takes like 20 seconds
is there a way to fix that?
how do I get the user who reacted to my message ?
!pypi asyncpraw
thank u
If you're using on_reaction_add, then you need to pass reaction and user kwargs.
!d discord.Reaction.users
async for ... in users(*, limit=None, after=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") representing the users that have reacted to the message.
The `after` parameter must represent a member and meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
Examples
Usage
```py
# I do not actually recommend doing this.
async for user in reaction.users():
await channel.send(f'{user} has reacted with {reaction.emoji}!')
```...
multiple users can react to one reaction so
The user kwarg represents a discord.Member/discord.User whom interacted.
ok
That returns an array, I believe what they want is only the user who reacted.
it returns an array of people who reacted
@client.command()
async def write(ctx , * , arg, content, allowed_mentions):
await ctx.send(arg, content, allowed_mentions=allowed_mentions)
``` don't work
why do you need
the allowed_mentions parameter
oh
what do you think * does
the space
space?
converts to kwargs
it eats all the arguments in discordpy and normally it eats all the positional ones
in dpy only
yes because otherwise I can not write for example: hello how are you
I can't use spaces
apply brain
so how do you think python is supposed to know what thr user typed for the arguments
after consuming every thing
you gotta do,
(arg, allowed_mentions, *, content)
i gotta go afk
k ty
object 'datetime.datetime' has no atribute delta?
!e
import datetime
print(dir(datetime.datetime))
@boreal ravine :white_check_mark: Your eval job has completed with return code 0.
['__add__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__radd__', '__reduce__', '__reduce_ex__', '__repr__', '__rsub__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', 'astimezone', 'combine', 'ctime', 'date', 'day', 'dst', 'fold', 'fromisocalendar', 'fromisoformat', 'fromordinal', 'fromtimestamp', 'hour', 'isocalendar', 'isoformat', 'isoweekday', 'max', 'microsecond', 'min', 'minute', 'month', 'now', 'replace', 'resolution', 'second', 'strftime', 'strptime', 'time', 'timestamp', 'timetuple', 'timetz', 'today', 'toordinal', 'tzinfo', 'tzname', 'utcfromtimestamp', 'utcnow', 'utcoffset', 'utctimetuple', 'weekday', 'year']
@boreal ravine :white_check_mark: Your eval job has completed with return code 0.
['MAXYEAR', 'MINYEAR', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'date', 'datetime', 'datetime_CAPI', 'sys', 'time', 'timedelta', 'timezone', 'tzinfo']
@drifting tulip timedelta maybe
well, i get that, but the question is how, there must be some documentation from discord behalf or something
There is not an official documentation by Discord. Conversely, you can find numerous resources on GitHub.
!pypi discord-ext-ipc
A discord.py extension for inter-process communication.
that?
How to handle errors from custom checks?
how can i fix this ?
An error handler?
I need to handle the error of the specific command which use that custom check
I have no clue what you mean
Try this:
from discord import Client
```,
```py
self.client = Client
!d discord.ext.commands.CheckFailiure
it raises a CheckFailture iirc
You have to just commands.Bot to use commands
or you can raise your own error
!d discord.ext.commands.CheckFailure
exception discord.ext.commands.CheckFailure(message=None, *args)```
Exception raised when the predicates in [`Command.checks`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command.checks "discord.ext.commands.Command.checks") have failed.
This inherits from [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError")
^
Use this
wont work idk if i am doing something wrong or its the code
an error handler is something that handles discord errors, because normal try/except statements won't catch the errors. You would have to make a error handler, for example,
@my_command.error
async def error(ctx, error: commands.CommandError):
if isinstance(...):
# code...
if you do try/except it would ignore it and instead raise the same error. It happened to me when I was making a cooldown command.
However, for normal errors you can use a try/except.
You want to use commands?
I only put ctx there if you wanted to send something
show us the code
You can't use discord.Client for commands
or you can try this
you can use commands.Bot
bot = commands.Bot(command_prefix=None ...) (don't put None for command_prefix it was only an example)
import discord
from discord import client
from discord.ext import commands
class Commands(commands.Cog):
def init(self, client):
self.client = client
@client.command()
async def ping(ctx):
await ctx.send(f'Your ping is {round(client.latency * 1000)}ms')
@client.command()
async def server(ctx):
name = str(ctx.guild.name)
description = str(ctx.guild.description)
owner = str(ctx.guild.owner)
id = str(ctx.guild.id)
region = str(ctx.guild.region)
memberCount = str(ctx.guild.member_count)
icon = str(ctx.guild.icon_url)
embed = discord.Embed(title=name + " Server Information",
description=description,
color=discord.Color.blue())
embed.set_thumbnail(url=icon)
embed.add_field(name="Owner", value=owner, inline=True)
embed.add_field(name="Server ID", value=id, inline=True)
embed.add_field(name="Region", value=region, inline=True)
embed.add_field(name="Member Count", value=memberCount, inline=True)
await ctx.send(embed=embed)
def setup(client):
client.add_cog(Commands(client))
*you don't have to use it, my mistake
thats the code
!code
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.
try:
import discord
from discord import Client
from discord.ext import commands
class Commands(commands.Cog):
def init(self, client):
self.client = Client
@client.command()
async def ping(ctx):
await ctx.send(f'Your ping is {round(client.latency * 1000)}ms')
@client.command()
async def server(ctx):
name = str(ctx.guild.name)
description = str(ctx.guild.description)
owner = str(ctx.guild.owner)
id = str(ctx.guild.id)
region = str(ctx.guild.region)
memberCount = str(ctx.guild.member_count)
icon = str(ctx.guild.icon_url)
embed = discord.Embed(title=name + " Server Information",
description=description,
color=discord.Color.blue())
embed.set_thumbnail(url=icon)
embed.add_field(name="Owner", value=owner, inline=True)
embed.add_field(name="Server ID", value=id, inline=True)
embed.add_field(name="Region", value=region, inline=True)
embed.add_field(name="Member Count", value=memberCount, inline=True)
await ctx.send(embed=embed)
def setup(client):
client.add_cog(Commands(client))
try removing from discord import client or do what excelgames said, from discord import Client (notice the capital C)
also if you're removing import Client then add a commands.bot
But client will not work for commands, right?
@stark geyser try this
client = discord.Client()
however I would use commands.Bot()
plus client isn't a good name, use bot instead
also in the embed = discord.Embed() you can use f strings
instead of name + "server information"
I know
can someone help me acheive embeds like img1
ive tried and failed as in img2 the width of the embeds are not same
f"{name} + Server Information" (I know you know I was talking to unknown)
that looks like a picture
i have 2 sets of code 1 for the normal commands and then the 1 for music then combining them together if that could be problem
nope its text
really?
seems like a perk of djs
however you can just add an image
!d discord.Embed.set_image
set_image(*, url)```
Sets the image for the embed content.
This function returns the class instance to allow for fluent-style chaining.
Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the image.
doesnt work
😦
commands.Bot()
@stark geyser try it
aight ill try
!d discord.ext.commands.Bot || please work
class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
LET'S GOO!!
what y'all even doing
Hi
anyways command_prefix, and stuff are all kwargs
No
@stark geyser If it's a cog, try this:
import discord
from discord import Client
from discord.ext import commands
class Commands(commands.Cog):
def init(self, client):
self.client = Client
@commands.command()
async def ping(ctx):
await ctx.send(f'Your ping is {round(client.latency * 1000)}ms')
@commands.command()
async def server(ctx):
name = str(ctx.guild.name)
description = str(ctx.guild.description)
owner = str(ctx.guild.owner)
id = str(ctx.guild.id)
region = str(ctx.guild.region)
memberCount = str(ctx.guild.member_count)
icon = str(ctx.guild.icon_url)
embed = discord.Embed(title=name + " Server Information",
description=description,
color=discord.Color.blue())
embed.set_thumbnail(url=icon)
embed.add_field(name="Owner", value=owner, inline=True)
embed.add_field(name="Server ID", value=id, inline=True)
embed.add_field(name="Region", value=region, inline=True)
embed.add_field(name="Member Count", value=memberCount, inline=True)
await ctx.send(embed=embed)
def setup(client):
client.add_cog(Commands(client))
if you want to remove a help command do help_command=None
and the other one I forgot
the bot works but the command isnt recognised now
well i've got a lot of embeds to do and its annoying to make an image for everything :/
I know, I'll fix it now.
h
code?
@stark geyser try this:
import discord
from discord import Client
from discord.ext import commands
class Commands(commands.Cog):
def init(self, client):
self.client = Client
@commands.command()
async def ping(self, ctx):
await ctx.send(f'Your ping is {round(self.client.latency * 1000)}ms')
@commands.command()
async def server(self, ctx):
name = str(ctx.guild.name)
description = str(ctx.guild.description)
owner = str(ctx.guild.owner)
id = str(ctx.guild.id)
region = str(ctx.guild.region)
memberCount = str(ctx.guild.member_count)
icon = str(ctx.guild.icon_url)
embed = discord.Embed(title=f"{name} Server Information",
description=description,
color=discord.Color.blue())
embed.set_thumbnail(url=icon)
embed.add_field(name="Owner", value=owner, inline=True)
embed.add_field(name="Server ID", value=id, inline=True)
embed.add_field(name="Region", value=region, inline=True)
embed.add_field(name="Member Count", value=memberCount, inline=True)
await ctx.send(embed=embed)
def setup(client):
client.add_cog(Commands(client))
...
This should work now.
that's my boy
'Commands' object has no attribute 'client'
on which line?
why did you do init lmao
idk i can dm u the whole bot code if u want
here's init, not _init_
@stark geyser Now try this:
import discord
from discord import Client
from discord.ext import commands
class Commands(commands.Cog):
def __init__(self, client):
self.client = Client
@commands.command()
async def ping(self, ctx):
await ctx.send(f'Your ping is {round(self.client.latency * 1000)}ms')
@commands.command()
async def server(self, ctx):
name = str(ctx.guild.name)
description = str(ctx.guild.description)
owner = str(ctx.guild.owner)
id = str(ctx.guild.id)
region = str(ctx.guild.region)
memberCount = str(ctx.guild.member_count)
icon = str(ctx.guild.icon_url)
embed = discord.Embed(title=f"{name} Server Information",
description=description,
color=discord.Color.blue())
embed.set_thumbnail(url=icon)
embed.add_field(name="Owner", value=owner, inline=True)
embed.add_field(name="Server ID", value=id, inline=True)
embed.add_field(name="Region", value=region, inline=True)
embed.add_field(name="Member Count", value=memberCount, inline=True)
await ctx.send(embed=embed)
def setup(client):
client.add_cog(Commands(client))
stop spoonfeeding him
did you try it?
_ _
yh tried it
Hmm, I don't know.
stop spoonfeeding him
?
replace self.client = Client to self.client = client
no bro you know i think they're using discord.Client in main.py
@stark geyser can you send main.py code
haiiiii
can u make a embed value blank or no
yeah, put, "\u28000"
as the value
okay
Thank you.
its okay, shit happens
🙂
you can make a class and instead of commands.command() you can do something like
class discordbot(Bot):
def __init__(self):
super.().__init__(command_prefix=...)
@self.command()
async def command(ctx):
# code...
bot = discordbot()
bot.run(TOKEN)
@stark geyser try:
class Commands(commands.Cog):
def __init__(self, client):
self.client = client
but....but...
use small c
why not this 🚶♂️
is there a way to make it completely blank?
theres still some space between it
wont go away
oh, alright
beautiful
why can't you do this
👍
also is there a way to do something like this in an embed :
"
1 = optional
2 = required
"
like 1 message with 2 lines in it
grammatically that's incorrect, since can't is basically "can not", so this says "why can not you do this" which is bad English. However, "why can you not do this" is better English, but using "can't" is a contraction, but "why can't you do this" is correct, but if you split it up it's incorrect.
How interesting...
hey guys, i would need some help with a discord bot that im coding atm because it doesnt seem to work c:
import discord
from discord import channel
from discord.ext import commands
from discord.flags import Intents
Intents = discord.Intents.default()
Intents.members = True
client = commands.Bot(command_prefix= '!', Intents=Intents)
@client.event
async def on_ready():
print("Bot is ready")
print("------------")
@client.command()
async def hello(ctx):
await ctx.send("hi")
@client.event
async def on_member_join(member):
channel = client.get_channel(763454059931107372)
await channel.send("Welcome")
client.run('BotToken')
there it is
it doesnt detect when someone joins
idk why
enable intents.members
nope
oh you did
ye
uhm
have you enabled the server members privileged intent in the dev portal?
yeah i did
weird
yeah it is
did you get someone to join?
yeah, multiple times
Is the event triggered? Add a print statement to see
i tried to do that but that doesnt work either
So not triggered?
nope
And you sure someone did join?
!d discord.on_member_join
discord.on_member_join(member)``````py
discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
try printing it
yeah
well i did
and?
nothing happened
huh
idfk
Before your client.run can you print dict(client.intents)
or maybe use listen()
@client.listen ?
@client.listen**()**
kk
hey @velvet tinsel i think i know it now its actually nothing related to code lmao
All embeds with text (so not the header images) have an full width hidden image
ok
and?
uhm
yeah
oh
@client.event
# ...
@client.command()
# ...
k
Before client.run, in the first indentation level
did that
got this now
import discord
from discord import channel
from discord.ext import commands
from discord.flags import Intents
Intents = discord.Intents.default()
Intents.members = True
client = commands.Bot(command_prefix= '!', Intents=Intents)
@client.event
async def on_ready():
print("Bot is ready")
print("------------")
@client.event
async def on_member_join(member):
print("hi")
@client.command()
async def hello(ctx):
await ctx.send("hi")
dict(client.intents)
client.run('BotToken')
alr
still doesnt work
Your not printing 🤔
nope
I'm asking you to print
wha
uh
am i suposed to see something special?
this?
'guilds': True, 'members': False, 'bans': True, 'emojis': True, 'integrations': True, 'webhooks': True, 'invites': True, 'voice_states': True, 'presences': False, 'guild_messages': True, 'dm_messages': True, 'guild_reactions': True, 'dm_reactions': True, 'guild_typing': True, 'dm_typing': True
Yes this means you didn't set up the intents properly
andy's smart
Don't use the Class name as variable name
he werry smort
intents = discord.Intents.default() -> intents = discord.Intents.all()
I was gonna say that but I thought default() is ok
just copy pasta that?
default doesn't contain members intent
nor presence, tho presence is not always needed
well you gotta understand why you do that
andy was gonna explain that
copy and pasta 😋
They are adding it lol, they just have an uppercased I in their intents variable which is causing this issue
oh well
Intents -> intents

so i just have to put that in my code?

how
Discord Dev Portal -> OAuth2 -> General
Astro
my bot was hosted on heroku, but after a while it went offline and doesnt want to come back anymore... can some1 help me?
Read 1st (heroku section): #discord-bots message
Read 2nd: #discord-bots message
you missed )
In fact I was looking for that
It took me a while but you said it first -.-
I got better eyes
I am short sighted
nah, I'm actually far sighted and I use discord on my tv
On tv, you are joking right?
I dont even have a TV -.-
!ot :D
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
Apologies
!ot-names
Off-topic channels
There are three off-topic channels:
• #ot0-psvm’s-eternal-disapproval
• #ot1-perplexing-regexing
• #ot2-never-nester’s-nightmare
The channel names change every night at midnight UTC and are often fun meta references to jokes or conversations that happened on the server.
See our off-topic etiquette page for more guidance on how the channels should be used.
They changed the name of the command
oh~
Oh~
imagine impersonating me
I don’t want to change my name into “icy” and my profile picture is perfectly suitable, thanks.
It’s cool how you can change your name and your profile picture and be a completely different person
h.. how did you know
LunaTheGod
magik
import discord
import keep_alive
import os
client = discord.Client()
token = os.environ.get("Hecker")
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startsWith('$sudo heck'):
user = next(iter(message.mentions, None))
if not user:
return
await message.channel.send(f'content {user.mention} more content')
^ error
help
Send error msg
the indentation is messed up
correct the indentation?
!indent
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
Did u fix the indentation
i tried
Send ss
@manic wing permission needed for ctx.command? or do you want this for something like a help command?
@cedar stream
Still indented wrong, indent it one more time
Read this @granite yew
ctx.command
Whats ur use case
{', '.join(map(lambda perm: f'`{perm}`', ctx.command.missing_perms))} permission{'' if len(error.missing_perms) <= 1 else 's'} to execute the `{ctx.command.name}` command." ```
@cedar stream
Or use an error handler
why was i born so fuckin dumb
no thats in an error handler - i meant the in a help command version oops
the try one
that is an error handler
traceback scrapping, okay one second
Like, you specify what you want to happen when specific error happens
bruh i know what that is
enslo you dont know what youre talking about
Indent lines 19 and 20 once
can you please not comment on my message i wasn't asking for help
I thought u said what 😂
@manic wing
import tracceback
try:
check = command_object.checks[0]
check(0)
except Exception as e:
try:
*frames, last_frame = traceback.walk_tb(e.traceback)
frame = last_frame[0]
first = (frame.f_locals['perms'])
joined_first = (" ".join(first))
first_replaced = joined_first.replace("", " ")
final = first_replaced.title()
except:
final = "No perms required"
indents are messed up
i fixed the error
but why wouldn't it come online
@cedar stream
also don't mind my var names I know they suck
You never did client.run
time to make that one line
the discord mute thing
ty
I want help
@client.command()
@commands.check(check_Mod)
async def OFF(ctx, seconds:float):
embed = discord.Embed(title = "OFF", description = f"{ctx.message.author.mention} turned off me for {round(seconds)} seconds",)
await ctx.send(embed = embed)
await client.close()
await asyncio.sleep(seconds)
await client.connect()
embed = discord.Embed(title = "Turned on", description = f"I came back after {round(seconds)}")
await ctx.send(embed = embed)
AIM - SENDING MESSAGE AFTER BOT RESTARTED USING A COMMAND
PROBLEM- SENDS ONLY TILL OFF EMBED
I KNOW IT SOMEWHERE THAT IT WONT WORK THIS WAY , THEN HOW WILL IT WORK
chill with the caps, and don't try to ping at-here or at-everyone please
It won't work cz iirc, when u do client.connect(), it will start the bot as if u just started it... Without any cache or something
Nope
and all
I thought of a json or txt file which will store the message id of my restart command's output and edit it on_ready will that work
Sure
Mby use on_connect instead of on ready
@spring flax it aint workin
try:
check = command.checks[0]
check(0)
except Exception as e:
try:
*frames, last_frame = traceback.walk_tb(e.traceback)
frame = last_frame[0]
first = (frame.f_locals['perms'])
joined_first = (" ".join(first))
first_replaced = joined_first.replace("", " ")
final = first_replaced.title()
except:
final = "No perms required"
Nvm
But on_ready is not guaranteed to only be called once
error?
'AttributeError' object has no attribute 'traceback when I catch the second exception
this is on a command that requires perms
Index error on a command that doesnt require perms - i assume thats how it should be
can you screenshot the code
Hello, I'm trying to create a guess-the-number game with a bot. Even if I put if message.author == client.user: return, the bot answers itself. Any idea?
Here the code:
`@client.event
async def on_message(message):
if message.author == client.user:
return
msg = message.content
if msg.startswith("£hello"):
greeting = random.choice(hellos_list)
await message.channel.send(greeting)
if msg.startswith("£support"):
response = random.choice(possible_responses)
await message.channel.send(response)
if msg.startswith("£guess"):
number = random.randrange(20)
await message.channel.send("Guess the number! (0-20)")
if msg == str(number):
await message.channel.send("Right!")
else:
await message.channel.send("Wrong. Try again!")`
use three `'s
!codeblacks
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.
async def on_message(message):
if message.author == client.user:
return
msg = message.content
if msg.startswith("£hello"):
greeting = random.choice(hellos_list)
await message.channel.send(greeting)
if msg.startswith("£support"):
response = random.choice(possible_responses)
await message.channel.send(response)
if msg.startswith("£guess"):
number = random.randrange(20)
await message.channel.send("Guess the number! (0-20)")
if msg == str(number):
await message.channel.send("Right!")
else:
await message.channel.send("Wrong. Try again!")
Try just doing if author.bot: return
Already done,
This will return if any bot is the author
Maybe I'm only missing where to put it
your code seems right, maybe its a problem with your run instance?
Attach a debugger and see what happens
if theres nothing wrong maybe try comparing the ids
Put a breakpoint at start of event
client.run(TOKEN)
by that I mean if you restarted your bot after u saved your changes
Are u using discord.Client or commands.Bot
oh yes
client.event
show where your client is defiend @wanton jacinth
No I mean, is client a discord.Client instance or commands.Bot instance
client = discord.Client()
TOKEN = "censured"
possible_responses = encourage_list.list
hellos_list = hello_all_languages.list
@client.event
async def on_ready():
print("Logged as {0.user}".format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if author.bot:
return
msg = message.content
if msg.startswith("£hello"):
greeting = random.choice(hellos_list)
await message.channel.send(greeting)
if msg.startswith("£support"):
response = random.choice(possible_responses)
await message.channel.send(response)
if msg.startswith("£guess"):
number = random.randrange(20)
await message.channel.send("Guess the number! (0-20)")
if msg == str(number):
await message.channel.send("Right!")
else:
await message.channel.send("Wrong. Try again!")
client.run(TOKEN)```
this is the whole thing
Ok It’ s a client
discord.Client
Actually now i tried to put author.bot and it's saying that author is not definied
print(client.user.id)
What r u trying to do?
Since u are trying to make commands you should consider using commands.Bot, it can do everything client can + some other stuff like commands
i'll try that
return if author is the bot
Why not this?
If message.author != client.user:
Code…
Its a subclass of discord.Client so it has everything client has https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#bots
Already tried
Ig It’ s just cleaner since everything doesn’t need to be indented
Nicer to look at
how i use api to send gif
when i print the id are the same
You can either send a gif or try send(file=File(filename))
from gif
?
ah nothing
Maybe i can say if message.author.id != the id i got it it can work
mistake type
Try replacing it with if message.author.bot: return
So it wont respond to any bot
Ok
Didn't work
What does message.author.bot return
Nothing?
@wanton jacinthpep8 ```Imports should be grouped in the following order:
Standard library imports.
Related third party imports.
Local application/library specific imports.
```py
import random
import discord
import encourage_list
import hello_all_languages
How would I be able to have a bot send this as one msg instead of multiple for each row?
Use \n for new line
client = discord.Client()
TOKEN =
possible_responses = encourage_list.list
hellos_list = hello_all_languages.list
@client.event
async def on_ready():
print("Logged as {0.user}".format(client))
@client.event
async def on_message(message):
# if message.author == client.user:
# return
if message.author.bot:
return
msg = message.content
if msg.startswith("£hello"):
greeting = random.choice(hellos_list)
await message.channel.send(greeting)
if msg.startswith("£support"):
response = random.choice(possible_responses)
await message.channel.send(response)
if msg.startswith("£guess") and message.author.id != 921476286193483786:
number = random.randrange(20)
await message.channel.send("Guess the number! (0-20)")
if msg == str(number):
await message.channel.send("Right!")
else:
await message.channel.send("Wrong. Try again!")
client.run(TOKEN)```
Can you send a ss so I can see indents etc.
what do u mean
remove token first
Screen shot
whats the error?
but the way this works is that it sends one line then sends another how would i set each row into a list or smth like that so that i can then send as one msg from the bot
bro indent mean space
lmao i am very bad in explaination
why # there
caseu he changed n commented it out
hmm
I am trying to create a guess the number game but the bot responds to itself
maybe keeps it as references if didnt work?
But in the other cases it doesnt
provisionally
NameError: name 'timeout' is not defined
do i need to import smth for this
does anyone know
What library are u using?
make it a var and random.choice
disnake
Then it should work
did i even use it properly
define it
await timeout(duration=10, reason=None)
Hb member?
am not sure but is message.author.id a string or integer ?
sorry i dont understand...
i use discord.py lmao
!d disnake.Member.timeout
await timeout(*, duration=..., until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Times out the member from the guild; until then, the member will not be able to interact with the guild.
Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.
You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.
New in version 2.3.
You do member.timeout()
@wanton jacinthyou also get new random number each time u do £guess, i would put in something like wait_for()
await member.timeout()
no, what...
@wanton jacinthhttps://discordpy.readthedocs.io/en/stable/api.html#discord.Client.wait_for
Ok thanks
I think I'm going to read some more documentation
best website to get anime gif api
first google result, https://developers.giphy.com/
The GIPHY Developer Portal is how you integrate the world's best GIF API into your business, app or project.
ty
i think discord itself uses that, not sure tho
ah yeah tenor
@slate swanhttps://rapidapi.com/collection/gif-api more references
Browse 5+ Image GIF APIs available on RapidAPI.com. Top Image GIF APIs include MojiPop, Giphy, RiteKit and more. Sign up today for free!
use disnake, its more recent and literally everything is the same
yah but discord.py is still working
wait have they stopped supporting discord.py?
yeah discontinued ages ago
oh shit
i tried out disnake, just put my code into google docs, ctrl+h and replaced discord with disnake and code works just fine idk
whye they dont display info about it on website
but why they stop supporting discord.py
same question :c
https://discordpy.readthedocs.io/en/stable/index.html weird they dont give any information about that on their website
on vsc
hi
hy
@slate swan @sinful pasture read this gist
ty
It will still work until a major update breaks it
Yea. With message content too it's gonna work
But yes, updates have ceased
!d discord.Intents.messages still exist :D
Whether guild and direct message related events are enabled.
This is a shortcut to set or get both guild_messages and dm_messages.
This corresponds to the following events...
It still needs to be enabled in order to get message content
lol danny is not professional
???
@maiden fablethanks bro, to bad no one wanted to continue on that project
you are?
me nub
you have no right to say that then
lmao
respect
Well, there are a numerous forks, but yea. No fork can be compared to dpy since dpy was a standard for discord bot making in Python
even if not pro, he coded a big project that helped alot of peoples make discord bots, cudos to him anyway
yah
@spring flax i reckon that traceback scraping doesnt work with 2.0 or something
hunter
yeah i would rather see dpy continued
Same
do you know how to get the permissions a command requires?
Hm?
You can't
o.O
danny is pro
whyyyy nottttt
Since discord.py doesn't know which error the Discord API gonna raise/send in a single line of code. There can be numerous errors
ik that
!d discord.ext.commands.MissingPermissions can be used tho
exception discord.ext.commands.MissingPermissions(missing_permissions, *args)```
Exception raised when the command invoker lacks permissions to run a command.
This inherits from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
nono not in an error
exception discord.ext.commands.MissingPermissions(missing_perms, *args)
error.missing_permissions exist
U gotta use the commands.MissingPermissions error
i think help dosnt show commands u dont have permissions for?
how do i do that in a help command 
like if u normal user and use help, it wont show kick ban etc
even if command exists
!d discord.ext.commands.HelpCommand.on_help_command_error @manic wing
await on_help_command_error(ctx, error)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
The help command’s error handler, as specified by [Error Handling](https://discordpy.readthedocs.io/en/master/ext/commands/commands.html#ext-commands-error-handler).
Useful to override if you need some specific behaviour when the error handler is called.
By default this method does nothing and just propagates to the default error handlers.
Use this (:
kick,ban commands is ez
lmao true
who said anything was hard?
me No one
nothing is impossible in this world LMAO
@commands.command(aliases=["k"])
@commands.has_permissions(kick_members=True)
async def kick(self, ctx, member:discord.User, *, reason="No reason provided"):
user = await self.bot.fetch_user(member.id)
try:
await user.send(f"You have been **kicked** from the {ctx.guild.name}\nreason: {reason}")
except:
pass
await ctx.send(f"{user.mention} **has been kicked.**\n*reason: {reason}*")
await ctx.guild.kick(user, reason=reason)```
i did this so u can both use @mention and their id

ik i do this same
lmao
Can someone help me work on a discord bot that graphs server statistics
😛
You know... member is already a discord.Member object since u typehinted it to discord.Member lol
!pypi matplotlib
try ur self, and come back with some codes and i think someone will get u help with errors etc
Well this isn't always the case... They can also ask how can they start it if they dk with what to begin lol
when i made it i had to do that to be able to use ID or @mention
No
I use this same
Code
@maiden fableyes otherwise i would't need fetch right 😉
With ban and unban too
yes
Whatever u specify, a name, a user id, or a mention, it will always convert it as long as it's a valid one (;
And tempban
Also consider using get instead of fetch repeatedly
ok but there was a reason i had to code this otherwise it would't be there 😛
!d discord.Guild.get_member
get_member(user_id, /)```
Returns a member with the given ID.
fetch makes an API request, get gets the object from the cache
trust me when i say i had to do this way to be able
or i would't even add that fetch
I just told u, rest your wish 🤷♂️
ama check it out later 😉

OT: have u guys seen matrix4 yet? (now that u posted neothumbup)
!ot and idk what's that
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
the movie
@honest vessel hey can u send a structure code for anime gif
Like : kick
Punch
With api
how do I do something like: the person says !help hello
the bot wants to include the thing that was said after the command, how do I do this?
class board:
def __init__(self):
self.spaces = [
[".", ".", ".", ".", ".", ".", ".", ],
[".", ".", ".", ".", ".", ".", ".", ],
[".", ".", ".", ".", ".", ".", ".", ],
[".", ".", ".", ".", ".", ".", ".", ],
[".", ".", ".", ".", ".", ".", ".", ],
[".", ".", ".", ".", ".", ".", ".", ],
]
def display(self):
for row in self.spaces:
for space in row:
print(space, end=" ")
print()
print("1 2 3 4 5 6 7")
print(" ")```
how would i make that
print as one msg
in discord from the bot
def cmd(ctx, *, arg):
await ctx.send(arg)
How do I include other text also?
i think it like guild.members or smth like that idk
like I just need like a number of members
len(guild.members)
Edited the msg
where would I implement that
variable = len(guild.members)
@honest vessel do u possibly know?
memberscount = len(guild.members)
await ctx.send("There are {} members in this server!".format(memberscount))```
or
```py
await ctx.send(f"There are {memberscount} members in this server!")```
something like that
also how am I supposed to set time
don't use format and f strings together
thnx
I want time to be on the y axis and # of numbers on the x axis
true - fixed
error
!e
a = 1
print(f"{}".format(a))
@maiden fable :x: Your eval job has completed with return code 1.
001 | File "<string>", line 2
002 | print(f"{}".format(a))
003 | ^
004 | SyntaxError: f-string: empty expression not allowed
See
In a bot how do I make sure that you can't kick urself?
add a check to see if its the author
@client.command()
async def rules(ctx,cmd,no):
print(cmd,no)
if cmd == "rule" :
rules = ["","1) Be respectly to everyone in this server irrespective of their age, gender and beliefs ",
"2) Irrelevant content in an unrelated channel is prohibited - don't spam in general or use music commands in spam",
" 3) Respect DM roles of a member - ask for permission if they have set to \"Ask for DMs\" and don't text them at all if its \"DMs Closed\" ",
"4) Only attach links in self promotion - links will be highly moderated and scanned for phising links or advertising",
"5) Targeted insults, slurs either personal or directed towards a group will not be tolerated",
"6) Abusing is allowed if both parties involved are okay with it",
"7) Don't tag Mods or Admins without any legitimate reasons ",
"8) Take roles which applies to you in real life - false picking of gender and age roles will lead to permanent ban from this server",
"9) Server staffs will not be responsible for any fraudment transactions"]
print(cmd,no)
text = rules[no]
print(text)
await ctx.send(text)```
what am I doing wrong ?
@maiden fablei fixed it hto above
event the print statements at top are not exexuting
how would i look into a msg that someone sent and find out if they said a specific word like...words...
cool
oh my bad, it looked so freaking sus
good for you
pls help
can someone help me figure out how to get time
I am trying to make a bot that the time goes on the y axis and the number of members is on the x axis
when i send my embed it looks like inline is true when it is false, so the fields are in a row when they shouldn't be
How to determine the number of deleted messages if there are messages older than 14 days in the chat?
you do like event on_message() and msg = ctx.content.message.split(" ")
and loop it and have a list of words u wanna check if match react
@bot.event
async def on_message(message):
words = ["jesus", "god"]
msg = message.content.lower()
for m in msg.split(" "):
if m in words:
# Do something
