We provide programming data of 20 most popular languages, hope to help you!
@client.command(name='say', help='Dire un message à votre place')
@commands.has_permissions(send_messages=True, manage_messages=True)
async def say(ctx, message, channelid):
await client.wait_until_ready()
channel = client.get_channel(channelid)
embed = discord.Embed(title="Message", color=discord.Color.dark_red())
embed.add_field(name="Nouveau message de {}".format(ctx.message.author), value="{}".format(message))
embed.set_footer(text="{}".format(ctx.message.author))
await channel.send(embed=embed)
Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send"
@client.command(name='say', help='Dire un message à votre place')
@commands.has_permissions(send_messages=True, manage_messages=True)
async def say(ctx, channel:discord.TextChannel, message):
#Embed making
embed = discord.Embed(title="Message", color=discord.Color.dark_red())
embed.add_field(name="Nouveau message de {}".format(ctx.message.author), value="{}".format(message))
embed.set_footer(text="{}".format(ctx.message.author))
await channel.send(embed=e)
async def say(ctx, channel:discord.TextChannel, *msg):
message = " ".join(msg)
#Embed making
embed = discord.Embed(title="Message", color=discord.Color.dark_red())
embed.add_field(name="Nouveau message de {}".format(ctx.message.author), value="{}".format(message))
embed.set_footer(text="{}".format(ctx.message.author))
await channel.send(embed=e)
c?say #text-channel-send Hello and Bye
" ".join(msg)
@client.event
async def on_member_join(member):
channel = discord.utils.get(member.guild.channels, name="👋│arrivals")
await channel.send(f"Welcome to Sleep's Gaming Cult {member.mention}! You are the ### member")
channel = client.get_channel(12324234183172)
await channel.send('hello')
#1
message = ctx.send("text")
#2
message = channel.send("text")
#3
message = channel.fetch_message(messageid)
#add reaction to message
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
"""SEND MESSAGE IN SPECIFIC CHANNEL"""
@client.command()
async def announce(ctx, channel: discord.TextChannel):
await channel.send("My text")
message = await channel.send('hmm…')
message_id = message.id
channel = client.get_channel(12324234183172) #channel id here
await message.channel.send('hello')
channel = client.get_channel(12324234183172)
await channel.send('hello')
channel = client.get_channel(12324234183172)
await channel.send('hello')
client.channels.get("<ID of the channel you want to send to>").send("<your message content here>")
await ctx.send("MESSAGE")
channel = client.channels.cache.get('757685515255545917');
channel.send('Pong');
await message.channel.send("Your message")
await bot.delete_channel("channle_name")
let channel = message.guild.channels.cache.get(c => c.name === 'the channel name')
channel.send("Your message")
await channel.message.send(f"{message.author.mention} is now level {self.users[author_id]['level']}! congrats!")
AttributeError: 'NoneType' object has no attribute 'message'
import discord
from discord.ext import commands
import json
import asyncio
class Levels(commands.Cog):
@commands.Cog.listener()
async def on_message(self, message):
if message.author == self.bot.user:
return
author_id = str(message.author.id)
bot = commands.Bot(command_prefix='!')
if author_id not in self.users:
self.users[author_id] = {}
self.users[author_id]['level'] = 1
self.users[author_id]['exp'] = 0
self.users[author_id]['exp'] += 1
if author_id in self.users:
if self.lvl_up(author_id):
channel = bot.get_channel('636399538650742795')
await channel.message.send(f"{message.author.mention} is now level {self.users[author_id]['level']}! congrats!")
def __init__(self, bot):
self.bot = bot
with open(r"cogs\userdata.json", 'r') as f:
self.users = json.load(f)
self.bot.loop.create_task(self.save_users())
async def save_users(self):
await self.bot.wait_until_ready()
while not self.bot.is_closed():
with open(r"cogs\userdata.json", 'w') as f:
json.dump(self.users, f, indent=4)
await asyncio.sleep(5)
def lvl_up(self, author_id):
author_id = str(author_id)
current_xp = self.users[author_id]['exp']
current_lvl = self.users[author_id]['level']
if current_xp >= ((3 * (current_lvl ** 2)) / .5):
self.users[author_id]['level'] += 1
return True
else:
return False
channel = bot.get_channel(636399538650742795)
await channel.send(f"{message.author.mention} is now level {self.users[author_id]['level']}! congrats!")
channel = client.get_channel(12324234183172)
await channel.send('hello')
@bot.command()
async def lvl_up(member: discord.Member):
"""Send a level up message"""
channel = bot.get_channel(channel_id) # channel id should be an int
if not channel:
return
await channel.send(f"GG {member}, u lvled up") # Whatever msg u want to put
@bot.command()
async def Hello(ctx):
channel = bot.get_channel(Insert Channel ID)
await channel.send('Hello')
channel = client.get_channel(12324234183172)
await channel.send('hello')
await ctx.send("MESSAGE")
^
SyntaxError: 'await' outside function``` i get this error when i try to run it, anyone has a fix for this?
^
SyntaxError: 'await' outside function``` i get this error when i try to run it, anyone has a fix for this?