Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- from discord.ext import commands
- import os
- client = commands.Bot(command_prefix='b!')
- client.remove_command('help')
- @client.event
- async def on_command_error(ctx, error):
- if isinstance(error, commands.CommandNotFound):
- await ctx.channel.send(f"コマンドが正しくありません。\nb!helpを参照してください。\n実行コマンド:{ctx.content}")
- @client.event
- async def on_ready():
- ch = await client.fetch_channel("672431630656208910")
- await ch.send("ブロッコリーが起動しました!\nブロッコリーは起動しないか、ブロッコリーシステムが起動したのか!")
- @client.event
- async def on_message(message):
- if message.author.bot:
- # もし、送信者がbotなら無視する
- return
- GLOBAL_CH_NAME = "broliy-global" # グローバルチャットのチャンネル名
- if message.channel.name == GLOBAL_CH_NAME:
- # broliy-globalの名前をもつチャンネルに投稿されたので、メッセージを転送する
- await message.delete() # 元のメッセージは削除しておく
- channels = client.get_all_channels()
- global_channels = [ch for ch in channels if ch.name == GLOBAL_CH_NAME]
- # channelsはbotの取得できるチャンネルのイテレーター
- # global_channelsは broliy-global の名前を持つチャンネルのリスト
- embed = discord.Embed(title="Global",description=message.content, color=0x00bfff)
- embed.set_author(name=message.author.display_name,icon_url=message.author.avatar_url_as(format="png"))
- embed.set_footer(text=f"{message.guild.name} / {message.channel.name}",icon_url=message.guild.icon_url_as(format="png"))
- # Embedインスタンスを生成、投稿者、投稿場所などの設定
- for channel in global_channels:
- # メッセージを埋め込み形式で転送
- await channel.send(embed=embed)
- @client.command()
- async def help(ctx, serverid):
- await ctx.send('>>> ヘルプを表示しています。\nb!help 今表示してるやつだよ\nb!youtube 開発者のYouTubeチャンネル表示\nb!intro_bot このBOTの紹介ビデオを表示するよ!\nb!server_list 公認サーバーのリストを表示')
- @client.command()
- async def youtube(ctx, serverid):
- await ctx.send('>>> 開発者ぶろりーのYouTubeドス!\nhttps://www.youtube.com/channel/UCbp2wAJ1JBYGwXeAQLICAUw?view_as=subscriber%60%60%60')
- @client.command()
- async def intro_bot(ctx, serverid):
- await ctx.send('>>> BROLIY SYSTEMの紹介動画です。\n-まだ無い..許してヒヤシンス-')
- @client.command()
- async def server_list(ctx, serverid):
- await ctx.send('>>> 公認サーバーのリストです。\n【公式】マイクラ採掘鯖 -石鯖- \nhttps://discord.gg/RGwTZzf/nのぶりんマイクラ逃走中サーバー/nhttps://discord.gg/y3YYAng/n【公式】MCBEbans -統合版荒らしデータベース-\nhttps://discord.gg/92eH2U7')
- @client.command()
- async def restart(ctx, serverid):
- await ctx.send('bot自体を再スタートします。')
- os.system("shutdown -r -t 0")
- @client.command()
- async def runcmd(ctx, *, cmd):
- k = os.system(cmd)
- await ctx.send(k)
- @client.command()
- async def leaveserver(ctx, serverid):
- guild = fetch_guild(serverid)
- await guild.leave()
- await ctx.send(f"{guild.name}から退出しました。")
- client.run('aaaaa')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement