Skip to content
Advertisement

I’ve followed all the instructions in a tutorial for a bot, and why doesn’t it work?

This code i’m using to try to make a discord bot that will change people’s nicknames in my server for them, won’t work.

from discord.ext import commands
from discord import embeds
from discord import message
import random
from typing import ValuesView
import os
from discord.ext.commands.core import has_guild_permissions

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

@client.event
async def on_ready():
    print('Gilbert is now online!')

@client.command(pass_content=True)
async def changenick(ctx, member: discord.Member, nick):
    await member.edit(nick=nick)
    await ctx.send(f'Nickname has been changed for {member.mention}.')

client.run=('mydiscordtoken')

Here’s what my terminal and member list look like

Advertisement

Answer

client.run is not a variable, as you have treated it in your question, but instead more similar to a function. Replacing your last line with the following should fix your problem.

client.run('mydiscordtoken')
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement