async def infoactivity(self,ctx, mus:commands.MemberConverter=None): print(f'{ctx.message.author.name}({ctx.message.guild.name})_'+ ctx.message.content ) try: await self.bot.request_offline_members(ctx.guild) except: pass if mus is None: info = ctx.message.author else: info = mus if info.activity is None: if str(info.status) == "offline": embed = discord.Embed(title=ut.textto("playinginfo-doing",ctx.message.author), description=ut.textto("playinginfo-offline",ctx.message.author), color=info.color) else: sete =False try: if info.voice.self_stream: embed = discord.Embed(title=ut.textto("playinginfo-doing",ctx.message.author), description=str(self.bot.get_emoji(653161518250196992))+ut.textto("playinginfo-GoLive",ctx.message.author), color=info.color) sete=True elif info.voice.self_video: embed = discord.Embed(title=ut.textto("playinginfo-doing",ctx.message.author), description=str(self.bot.get_emoji(653161517960658945))+ut.textto("playinginfo-screenshare",ctx.message.author), color=info.color) sete=True elif info.voice: embed = discord.Embed(title=ut.textto("playinginfo-doing",ctx.message.author), description=str(self.bot.get_emoji(653161518082293770))+ut.textto("playinginfo-invc",ctx.message.author), color=info.color) sete=True except: pass if not sete: if info.bot: embed = discord.Embed(title=ut.textto("playinginfo-doing",ctx.message.author), description=ut.textto("playinginfo-bot",ctx.message.author), color=info.color) elif "🌐"==ut.ondevicon(info): embed = discord.Embed(title=ut.textto("playinginfo-doing",ctx.message.author), description=ut.textto("playinginfo-onlyWeb",ctx.message.author), color=info.color) elif "📱"==ut.ondevicon(info): embed = discord.Embed(title=ut.textto("playinginfo-doing",ctx.message.author), description=ut.textto("playinginfo-onlyPhone",ctx.message.author), color=info.color) else: embed = discord.Embed(title=ut.textto("playinginfo-doing",ctx.message.author), description=ut.textto("playinginfo-noActivity",ctx.message.author), color=info.color) activ=info.activity embed.set_author(name=info.display_name, icon_url=info.avatar_url_as(static_format='png')) await ctx.send(embed=embed) else: for anactivity in info.activities: if anactivity.type == discord.ActivityType.playing: activName=ut.textto("playinginfo-playing",ctx.message.author)+anactivity.name elif anactivity.type == discord.ActivityType.watching: activName=ut.textto("playinginfo-watching",ctx.message.author)+anactivity.name elif anactivity.type == discord.ActivityType.listening: activName=ut.textto("playinginfo-listening",ctx.message.author).format(anactivity.name) elif anactivity.type == discord.ActivityType.streaming: activName=ut.textto("playinginfo-streaming",ctx.message.author)+anactivity.name elif anactivity.type == discord.ActivityType.custom: activName=ut.textto("playinginfo-custom_status",ctx.message.author) else: activName=ut.textto("playinginfo-unknown",ctx.message.author)+anactivity.name embed = discord.Embed(title=ut.textto("playinginfo-doing",ctx.message.author), description=activName, color=info.color) activ=anactivity embed.set_author(name=info.display_name, icon_url=info.avatar_url_as(static_format='png')) if anactivity.name == "Spotify": try: embed.add_field(name=ut.textto("playinginfo-title",ctx.message.author), value=activ.title) embed.add_field(name=ut.textto("playinginfo-artist",ctx.message.author), value=activ.artist) embed.add_field(name=ut.textto("playinginfo-album",ctx.message.author), value=activ.album) embed.add_field(name="URL", value=f"https://open.spotify.com/track/{activ.track_id}") #embed.add_field(name="経過時間", value=str(activ.duration.seconds/60)+str(activ.duration.seconds%60)) embed.set_thumbnail(url=activ.album_cover_url) except AttributeError: embed.add_field(name=ut.textto("spotify-local",ctx.author), value=ut.textto("spotify-cantlisten-wu",ctx.author)) embed.add_field(name=ut.textto("playinginfo-title",ctx.message.author), value=activ.details) embed.add_field(name=ut.textto("playinginfo-artist",ctx.message.author), value=activ.state) elif anactivity.type==discord.ActivityType.streaming: try: embed.add_field(name=ut.textto("playinginfo-streampage",ctx.message.author), value=activ.url) except: pass try: embed.add_field(name=ut.textto("playinginfo-do",ctx.message.author), value=activ.datails) except: pass elif anactivity.type==discord.ActivityType.custom: embed.add_field(name=ut.textto("playinginfo-det",ctx.message.author), value=str(anactivity)) else: try: vl = "" if activ.details: vl = f"{activ.details}\n" if activ.state: vl = f"{vl}{activ.state}\n" if vl == "": vl = "なし" embed.add_field(name=ut.textto("playinginfo-det",ctx.message.author), value=vl) except: pass await ctx.send(embed=embed)
# -*- coding: utf-8 -*- import discord from discord.ext import commands import asyncio import m10s_util as ut """↑様々な便利コマンド詰め合わせ ut.ondevicon(Member) オンライン状況に基づくデバイスアイコンテキストを返す。 ut.getEmbed(title,description,color,(name,value)...) Embedのお手軽生成。これ使ったのがあるから消そうにも消せない。 await ut.opendm(Member/User) DMチャンネルを返します。DMチャンネルが存在しないなんてことでは困らせません。 await wait_message_return(ctx,質問するテキスト,←の送信先,待つ時間): 入力待ちの簡略化。タイムアウトの例外キャッチを忘れずに ut.get_vmusic(bot,member) 思惟奈ちゃんの音楽再生機能でそのメンバーがきいている曲を返します。 """ class m10s_chinfo_rw(commands.Cog): def __init__(self, bot): self.bot = bot @commands.command(name="chinfo") async def command(self, ctx, target=None): if target is None: target = ctx.channel else: try: