Beispiel #1
0
        public async Task Create(CommandContext e, [Description("Give the ID of the channel you wish to create from the !instance channels command.")] int channelID)
        {
            InstanceObject.ChannelTemplate template = RPClass.ChannelTemplates.FirstOrDefault(x => x.Id == channelID);
            if (template != null)
            {
                DiscordChannel c = await e.Guild.CreateChannelAsync(template.Name, ChannelType.Text, parent : RPClass.InstanceCategory);

                if (template.Content.Count > 0)
                {
                    foreach (string content in template.Content)
                    {
                        if (content.StartsWith("File:"))
                        {
                            await c.SendFileAsync(content.Split(':')[1]);
                        }
                        else
                        {
                            await c.SendMessageAsync(content);
                        }
                    }
                }
                await e.RespondAsync($"Channel: {template.Name} created - {c.Mention}");
            }
            else
            {
                await e.RespondAsync("Enter a valid channel ID.");
            }
        }
Beispiel #2
0
        public async Task Add(CommandContext e, [Description("Give the ID of the channel you wish to create from the !instance channels command.")] int channelID)
        {
            InstanceObject.ChannelTemplate template = RPClass.ChannelTemplates.FirstOrDefault(x => x.Id == channelID);
            if (template != null)
            {
                int instanceID = 1;
                if (RPClass.InstanceList.Count > 0)
                {
                    instanceID = RPClass.InstanceList.Last().Id + 1;
                }

                DiscordChannel c = await e.Guild.CreateChannelAsync(instanceID + "-" + template.Name, ChannelType.Text, parent : RPClass.InstanceCategory);

                RPClass.InstanceList.Add(new InstanceObject.RootObject(instanceID, c.Id, template.Id));
                if (template.Content.Count > 0)
                {
                    foreach (string content in template.Content)
                    {
                        await c.SendMessageAsync(content);
                    }
                }
                RPClass.SaveData(7);
                await e.RespondAsync("Channel: " + template.Name + " created with ID: " + instanceID + ".");
            }
            else
            {
                await e.RespondAsync("Enter a valid channel ID.");
            }
        }