Вы используете команду asyn c без ожидания
for _ in range(5):
await msg()
Но ... Я очень уверен, что это вообще сработает, потому что вы хотите использовать функцию msg, лучшее решение -
a = 0
async def send_message_and_increment(ctx):
global a
a += 1
await ctx.send(a) # send to text_channel the user was in
await ctx.author.send(a) # send to the user (DM) that invoke the command
@Bot.command()
async def msg(ctx):
global a
for _ in range(5):
await send_message_and_increment(ctx)