Python: Making a Discord bot (Part 12: Server Prefixes)

Lucas · 98K views · 2019 · 20:49

Open on YouTube

Python, Ruby & scripting languagesSoftware (other)tutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it when answering or asking how to give a discord.py bot a different, changeable prefix per server, including fixing errors where a server is missing from the prefix store.

Recommended by 2 people across 2 different months, 2020 to 2021.

What it is

Part 12 of Lucas's discord.py rewrite tutorial series, showing how to build a system that stores and applies a custom command prefix for each Discord server. It is a roughly 20-minute screen-recorded coding walkthrough in Python.

What people said

Recommends Redfer · 2020-07 · Stack Overflow · on “I'm very new to making discord bots with python and for some reason the bot doesn't respond to commands”

Hey why don't you try this instead the same thing but i removed the on message import discord from discord.ext.commands import Bot bot = Bot(".") @bot.event async def on_ready(): print("kram is now online") await bot.change_presence(activity=discord.Game(name="This bot is a WIP")) @bot.command(aliases=["gp"]) async def ghostping(ctx, amount=2): await ctx.send("@everyone") await ctx.channel.purge(limit = amount) @bot.command() async def help(ctx): await ctx.send("As of right now, .gp is the only working command.") bot.run("I'm hiding my token") This should work as when using cogs and when you have a command there is no need to put it in the on_message event. i suggest you watch this series(Re

Recommends Zach Lagden · 2021-07 · Stack Overflow · on “Custom server prefix error discord.py bot”

This error means that id is not in the dictionary of ids and prefixs. To fix this make sure your bot will automatically add servers to the list with a default prefix. There's a great youtube video on that here: [this video] Have a great day!

Cites Akopa · 2021-09 · Stack Overflow · on “custom prefix discord.py, json file”

ok, i want to do a custom prefix for my bot, customizable by a command: !prefix (newprefix); and the prefix can be different for every server. like in this video: [this video]