'Trying to send message to channel when command is executed discord.py
Im trying to have this code automatically send a message in chat when someone executes it.
This code is to rename a channel, but the process may take a few mins and therefore id like to send a message right after the cmd is executed to tell the users to wait. any help would be appreciated.
import functions as func
from commands.base import Cmd
async def execute(ctx, params):
params_str = ctx['clean_paramstr']
guild = ctx['guild']
author = ctx['message'].author
new_name = params_str.replace('\n', ' ') # Can't have newlines in channel name.
new_name = new_name.strip()
if new_name:
return await func.custom_name(guild, ctx['voice_channel'], author, new_name)
else:
return False, ("You need to specify a new name for this channel, e.g. '{0}name <new name>'.\n"
"Run '{0}help template' for a full list of variables you can use like "
"`@@game_name@@`, `@@creator@@` and `@@num_others@@`.".format(ctx['print_prefix']))
command = Cmd(
execute=execute,
params_required=1,
gold_required=True,
admin_required=False,
voice_required=True,
creator_only=True,
)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
