H
H
Hanuka32362020-07-19 14:15:08
Python
Hanuka3236, 2020-07-19 14:15:08

How to find out the name of the discord server where the bot is located?

Here is my code:

import discord
import random
from discord.ext import commands

client = commands.Bot(command_prefix = "!")
@client.event
async def on_ready():
    print("Bot is running...")
@client.command()
async def test(ctx):
        emb = discord.Embed(title = " Title", color = discord.Color.red())
        emb.set_footer(text = "Имя сервера " + str(discord.Guild.name))
        await ctx.send(embed = emb)

Instead of the server name in the discord, the bot writes <member 'name' of 'Guild' objects>how to fix this? There are no errors in the console.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander, 2020-07-19
@Hanuka3236

try using ctx.message.guild.nameinsteaddiscord.Guild.name

B
bio, 2015-01-03
@Spacegrey

I did not quite understand what is meant, but I think it will help habrahabr.ru/post/119127 habrahabr.ru/post/144003

S
Sergey Vinogradov, 2015-01-03
@pettson

It's not clear what "stay in place" means... probably you need to wrap all elements in a container and set min-width for it :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question