コード例 #1
0
        public async Task AnnounceAsync([Remainder] string Announcement = null)
        {
            if (Announcement != null && Announcement.Length > 0)
            {
                var dbCon = DBConnection.Instance();
                dbCon.DatabaseName = BotConfig.Load().DatabaseName;
                if (dbCon.IsConnect())
                {
                    if (UserProfile.CanAdministrate(Context.User.Id, dbCon))
                    {
                        await Context.Message.DeleteAsync();

                        GlobalChannel GeneralChannel = ChannelData.FindChannelById("general");
                        if (GeneralChannel != null)
                        {
                            var embed = new EmbedBuilder()
                            {
                                Color = new Color()
                            };
                            embed.WithTitle("Global Announcement");
                            embed.WithDescription(Announcement);
                            embed.WithFooter("Global announcement by " + Context.User.Username + " at " + DateTime.UtcNow.ToShortTimeString());
                            await Message.PostGlobalAnnouncementAsync(embed, GeneralChannel, dbCon);
                        }
                        else
                        {
                            var Message = await Context.Channel.SendMessageAsync("Announcement failed. General chat could not be found?");

                            await Delete.DeleteMessage(Message);
                        }
                    }
                    dbCon.Close();
                }
            }
        }