I'm trying to make a completly new role in discord (with discord.py) but everything I try, doesn't work. I allready tried
await guild.create_role(name("R3KT")) #NameError: name 'guild' not defined
and
author = ctx.message.author
await client.create_role(author.server, name="role name") #NameError: name 'ctx' not defined
I've tried changing ctx and guild to 'client' but it still didn't work. if needed I'll send the whole code (without the discord name and bot key)
here's the entire code:
import discord
token = "bot-key"
client = discord.Client()
@client.event
async def on_ready():
print("Bot is online and connected to Discord")
@client.event
async def on_message(message):
message.content = message.content.upper()
if message.author == client.user:
return
if message.content.startswith("AS HELLO"):
await message.channel.send("works")
elif message.content.startswith("AS CREATEROLE"):
if str(message.author) == "myDiscName#6969":
author = message.author
await discord.create_role(author.server, name="R3KT")
elif message.content.startswith("AS GIVEROLE"):
if str(message.author) == "myDiscName#6969":
print("give role")
client.run(token)
on_message
or command events) – Eric Jin